Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When on iPhone 5, UITableView cuts off in 3.5 inch format

For some reason, the UITableView cuts off when on an iPhone 5. Instead of seeing the table view on the entire screen, I just see a blue background. Basically, it's behaving like I'm using a 3.5" inch screen. The only time it does work is when I set the view to "Retina 4 Full Screen" in Simulated Metrics. But the problem with that is then I have the opposite problems with 3.5 inch screens. Here are a couple of pictures (the view is currently set to "Freeform" in Simulated Metrics):

enter image description hereenter image description here

I have tried looking for similar questions, but none have helped. If it helps, I do have a MainWindow.xib. I am testing this using the iPhone 6.0 Simulator as well as an iPhone 4S 16GB. I will update this question if anything looks unclear. Any help is appreciated. Thank you.

like image 627
chrisjr Avatar asked Dec 02 '12 07:12

chrisjr


3 Answers

You probably don't have the proper autoresizing masks set. Try to set the mask to just UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight.

like image 151
D_4_ni Avatar answered Oct 17 '22 11:10

D_4_ni


Here's what i did. I started my xib file size as 3.5 in attributes inspector

And in my view controller i have this code, make sure you change the frame in viewDidAppear method

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    if ([self hasFourInchDisplay]) {
        self.myTableView.frame = self.view.frame;
    }
}

- (BOOL)hasFourInchDisplay {
    return ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 568.0);
}
like image 2
Puran Avatar answered Oct 17 '22 12:10

Puran


You need to resize your table, add one property autoresizingMask.

self.tableView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleHeight ;

One more thing you are adding tableView inside mainView(self.view) or any subView. You may have this problem.

Check Your mainView's bound and frame.

Hope this will help you.

like image 1
Nirav Jain Avatar answered Oct 17 '22 12:10

Nirav Jain