Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I expand UITableView to fill full screen on iPhone 5 using Interface Builder?

Is it possible to expand a UITableView with static cells to adjust automatically to the 4" iPhone 5 screen and expand the height of each UITableViewCell accordingly? If I create a simple UITableView in IB with 3 static rows, when I view it on the iPhone 3.5" display it looks fine but on the iPhone 4" display there is extra whitespace at the bottom. I tried playing with autolayout (I'm only interested in iOS6), setting autosizing options, etc. but to no avail.

BTW - I know I can set the height in code e.g. in heightForRowAtIndexPath: divide the bounds or frame height by number of rows (i.e. 3 rows). But I'm looking for something more dynamic.

example of iPhone resizing issue on 3.5" and 4"

like image 430
Click Ahead Avatar asked Feb 28 '13 17:02

Click Ahead


3 Answers

The problem was resolved by setting the AutoLayout property on the TableView. Once I did this the table resized accordingly. I also subsequently discover that I could do take care of resizing by setting the AutoSizing mask.

like image 79
Click Ahead Avatar answered Nov 12 '22 07:11

Click Ahead


I had a similar problem. In Xcode 6.4 I added constraints for my UITableView in the storyboard.

enter image description here

like image 44
Kiryl Belasheuski Avatar answered Nov 12 '22 07:11

Kiryl Belasheuski


Another way to solve (this worked for me) is to click the Apply 4-inch form factor button and extend your UITableView to the bottom of the screen.

enter image description here

like image 28
truthful_ness Avatar answered Nov 12 '22 06:11

truthful_ness