views:

111

answers:

2

I have an app, which has a top navigation bar and a bottom tab bar.

One of the tabs displays a table's XIB file with my custom controller.
This UITableView is created by a MyTableViewController class.

I have a problem with the table's size. The table's frame size is bad (it's the fullscreen iphone size, without the status/tab/navigation bar sizes taken into consideration) however it's placing is good (it starts under the navigation bar).

In the table's XIB (which is a separate XIB file that only holds the table), I've tried setting and removing the top/bottom (nav/tab) bars to change the table size.
It didn't help.

Then I tried customizing it from the controller:

- (void)viewDidLoad {
    self.view.frame = CGRectMake(0, 20, 320, 270); // a lot shorter than I need it, but just to prove the point
    [super viewDidLoad];
}

I've set a breakpoint there, and viewDidLoad is in fact getting called, but the table is of the same size.

What am I doing wrong?

+1  A: 

Make sure you have your "Springs & Struts" (Tools Menu > Size Inspector) in Interface Builder set so that it's a properly expanding/contracting view. Most likely, this will mean 4 solid red lines around the outside of the box, and two inside (no dotted lines visible).

Ben Gottlieb
Prody
+1  A: 

What if you call [super viewDidLoad] first before setting the frame. Since you are loading your view from XIB, it's possible that [super viewDidLoad] will override your self.view.frame = ...

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.frame = CGRectMake(0, 20, 320, 270); // a lot shorter than I need it, but just to prove the point
}
mfu
that works, thanks :) I was previosly setting the frame on a later event, that also worked
Prody