Illep
Illep

Reputation: 16841

Issue displaying uitableview in UIViewController - Not aligned

I dragged a uitableview component to my UIViewController in the Storyboard.

It appears as

enter image description here

Then when I ran the application, there's a space on the side. How to prevent this? enter image description here

Note: Initially this application was enabled autoLayout, and I removed it later on. Hope there's no effect for this error.

Upvotes: 0

Views: 145

Answers (6)

Piyush Mathur
Piyush Mathur

Reputation: 1607

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.

Upvotes: 1

Manoj
Manoj

Reputation: 1540

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-

  1. Use auto layout so this will solve the issue itself.
  2. 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.

Upvotes: 0

Burhanuddin Sunelwala
Burhanuddin Sunelwala

Reputation: 5343

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.

Upvotes: 0

Gil Sand
Gil Sand

Reputation: 6040

Add constraints on your tableview.

If you don't know how to, here is a simple step by step :

  1. Right clic or ctrl+drag the tableview (on the left side list) to View.
  2. Select Top space to top layout guide Repeat with Bottom space to bottom layout guide
  3. Repeat with Leading space to container margin
  4. Repeat with Trailing space to container margin

That should fix your issues.

Upvotes: 1

Thlbaut
Thlbaut

Reputation: 649

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

enter image description hereenter image description here

Upvotes: 0

Mohd Prophet
Mohd Prophet

Reputation: 1521

Check your screen size in Storyboard:

enter image description here

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

Upvotes: 0

Related Questions