Issue displaying uitableview in UIViewController - Not aligned - ios

I dragged a uitableview component to my UIViewController in the Storyboard.
It appears as
Then when I ran the application, there's a space on the side. How to prevent this?
Note: Initially this application was enabled autoLayout, and I removed it later on. Hope there's no effect for this error.

Add constraints on your tableview.
If you don't know how to, here is a simple step by step :
Right clic or ctrl+drag the tableview (on the left side list) to
View.
Select Top space to top layout guide Repeat with Bottom
space to bottom layout guide
Repeat with Leading space to
container margin
Repeat with Trailing space to container margin
That should fix your issues.

The answer on this link will surely help you.
https://stackoverflow.com/a/26708486/3396270
Though its Table view in your case you can use it with all the components by changing the settings as per their requirements.

Check your screen size in Storyboard:
And make sure you are running the application on same size of Simulator as in your storyboard.

If you uncheck the Translucent property of your Navigation Bar, it's going to fix it.

If you are not using AutoLayout then just write this code in your viewDidLoad Method
[tableView setAutoresizingMask:UIViewAutoresizingMaskFlexibleWidth | UIViewAutoresizingMaskFlexibleHeight];
You could also set the AutoresizingMask from your nib file.

What version of the xcode are you using? If it's okay with 5s and not okay with 6 and 6+ then you should change the size of the table manually or use autolayout. Storyboard which you'v used should have optimised for devices below 6. I you're using #3x image for splash screen then your app supports 6 and 6+ but it uses the same table size as what it is designed for 5s device size on simulator.
Solutions-
Use auto layout so this will solve the issue itself.
Else create outlet for table and changes it size according to the device width and height.
I have released an app using the above 2 solutions and its in the store now.

Related

Launch image adds margin

After adding my launch image using a xib (and I even tried the traditional launch image way as well) some of my view controllers have a strange right margin now. For example before I might have had a label whose width was the entire screen, and used auto layouts such that it was leading/trailing to the content margins, and now despite that after adding a launch image there is a margin (it's not on every screen, but definitely some). On one of my screens where this is most prevalent i'm using autolayout but overriding with constraints that I add programmatically. Not sure if that's related.
Has anyone experienced anything like this or does anyone know if adding launch screens affect the story board / view controllers in any way?
Thanks!
On the launch screen select your image view, then select the pin at the bottom right of xcode (3rd option). Make sure all constraints are set to 0, while making sure the red I is selected for each one when they are set and uncheck constraint to margins. Finally click add constraints :)
Hope this helps you!
Rachel

UIView Doesn't allow swipe down to see rest of the screen

I build a view that has contents which exceed the height of the iphone 6 screen vertically.
To test that out, I've set a specific height for my image (600pts) to guarantee that the whole content wouldn't fit on the screen of an iphone 6 and that you should swipe down to see the rest (the label "BYE").
However, when I run the simulator, I cannot swipe down to see the rest of the screen.
I've used Autolayout constraint and set a margin top/bottom between each components and the superview (I don't have any autolayout constraints issues/warning).
Here's the screenshot of the storyboard of my UIViewController:
Here's when I run the simulator, I cannot see the Label "BYE"(which is normal) but I cannot swipe down to see it.
I am using Xcode 6.1 and Swift.
Any suggestion and explanations?
Thanks a lot!
I have redone your screen and here are the steps. The reason for your issue is not setting proper constraints in autolayout. First you need to choose AnyWidth AnyHeight in Xcode which is in bottom of the storyboard.
Here is the screenshots of View in StoryBoard and its constraints
Constraints
Final Result in Simulator
Setting the constraint properly will work for you. Let me know if you have any issues in doing so. Sorry for the image i used its low quality one and its just for test.
EDIT
In Storyboard if you see the bottom of the screen you will see below image. In center of that image there is wAnyhAny.
you need add constraint to thoes components!
Otherwise, some components will be placed out of the screen!
You can learn how to use Autolayout from here
![enter image description here][1]At right bottom of storyboard in xcode you will see triangel Resolve autolayout isuue select in Reset to suggested constraint.

iOS 7 keep buttons at bottom in 3.5inch and 4inch

I haven't done iOS development in a while (since Xcode 4 and iOS 5). And I have a very noobish question:
How can I keep buttons at the bottom of a storyboard viewcontroller on both 3.5inch and 4 inch devices? Previously I could use 'origin' or something similar in the right side panel.
A quick solution, especially if you don't need to deal with rotation of elements much is to add some basic auto layout constraints to your view.
Once you have your button set in place in your view where you want it to stay in the view, select your View in the Storyboard and then from the Menu Select Editor -> Resolve Auto Layout Constraints -> Add Missing Constraints in View.
Simply doing that will give you what you want. Make sure you have auto layout enabled for your storyboard.
set autoresizing mask as shown in image to keep button at buttom in both 3.5 and 4.
i think you are using autolayout so apply first approach
with AutoLayout. add constrains for your widgets
without AutoLayout

IOS7 Tableview autolayout not work

Oh, I am having trouble with AutoLayout in IB(xcode 5, ios7), an IPad project.
Here is a view hierarchy in my project.
UIViewController->UIView->UITableView->UITableviewCell->UILabel。
And I add some constraints to UILable, (1.pin height, 2. Pin leading space to superview 3.pin trailing space to super view, 6 pin top space to superview.). But when I look in the portrait mode, I think it should change its' width to keep 2 and 3 constraints, but it didn't, can anyone give me a suggestion what should I do.
Thanks a lot!
Here is my screen shot in portrait mode and landscape mode.
I suppose I'm right when I say that you obtain the second screenshot when you select Landscape for the Orientation in the Simulated Metrics of your view controller. As the title of this section suggests, it's a simulation (might be different at run time). The warning message you have might be saying Frame for **** will be different at run time. Have you tried to run your app? Have your labels wrong positions/sizes ?

Layout messed up on iPhone 5

I use MainWindow.xib for the layout of my app. I set everything on the view controller attributes simulated metrics to iPhone 3.5 retina. There is no image set for the iPhone 5 Default, yet it still tries to run the app full screen on an iPhone 5, causing the screen to be all out of sorts. Any thoughts on fixing this?
Here is on 3.5" screen:
Here is on 4" screen:
You need the constraints on your labels and fields to be connected to the top of the view, not the bottom. By default, IB pins things to the closest edge. Use the pinning menu to achieve this, then delete the constraints that connect them to the bottom.
Alternatively you can switch to the 4" layout in IB and set things up there.
I have written about editing constraints in interface builder here, hopefully that will be useful to you.
As for fullscreen mode, I think Xcode will put -568.png image for you, you might want to check?
As for fixing the layout, it seems that all you need is to fix top strut on all text fields, so the top position is always the same.
set UITextField autoresizingMask to UIViewAutoresizingFlexibleBottomMargin
recipientLabel.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin;
nameLabel.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin;
...

Resources