The main screen of my app is a static table view with some options. With the new iPhone 5 I have to deal with an extra space on the bottom of the screen: I would like to increase the height of the cells accordingly to the screen dimension and to scale, consequently, the labels font size inside it. Is there any way to do it using only using autolayout? If not which is the best way?
I don't think it's good practice to stretch a table view's cells for the iPhone 5 resolution. The reason they gave you more pixels is so users could see more of the screen.
If you insist on doing this, you can set the row height in your table view delegate method, checking the screen height to see if it 568 points (the iPhone 5 height) using [[UIScreen mainScreen] bounds].size.height
:
// sets the height for a row based on indexPath
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
// check if the iPhone 5 is used by using the screen height
BOOL isIPhone5Used = ([[UIScreen mainScreen] bounds].size.height == 568.0f);
// set the height to a larger number for iPhone 5 rows
return (isIPhone5Used ? 50.0f : 44.0f); // this sets a height of 50 for iPhone 5 rows, and 44 for all other iPhones
}
You should customize it depending on the indexPath
, if you use different heights for various rows. Or, return one value if all rows are the same height.