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

5

5

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 here enter 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.

Seacock answered 2/12, 2012 at 7:36 Comment(0)
N
6

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

Neva answered 2/12, 2012 at 8:21 Comment(2)
I'm not too sure where to put that.Seacock
@Junior117 In the size inspector (i.sstatic.net/SzPi5.png) click on the two double arrows so that they light up in a stronger red.Neva
P
2

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);
}
Paraglider answered 15/11, 2013 at 18:17 Comment(0)
E
1

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.

Epilepsy answered 17/3, 2013 at 14:17 Comment(0)
R
1

Using Auto Layout you can just set constraints for the four margins of your table view then click add constraints

enter image description here

Ritaritardando answered 6/6, 2014 at 15:14 Comment(0)
H
0

Try one of these and see if they help:

myTableView.view.frame = self.view.bounds;
// or
myTableView.view.frame = self.view.frame;
Holds answered 2/12, 2012 at 8:39 Comment(1)
In what file do I put that and where?Seacock

© 2022 - 2024 — McMap. All rights reserved.