Reputation: 301
I am setting the frame of a UITableView in viewDidLoad, also after the device is rotated to ensure that it remains in the proper location. Here is my code:
- (void)viewDidLoad
{
[self setItemBoundaries];
}
- (void) setItemBoundaries {
if (UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation)) {
self.raceTable.frame = CGRectMake(20,502,728,472);
}
else {
self.raceTable.frame = CGRectMake(20,20,492,708);
}
}
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[self setItemBoundaries];
}
However when the app loads, the table is sized incorrect (only on landscape mode):
After rotating through portrait back to landscape, it looks fine:
What am I doing wrong?
Upvotes: 0
Views: 266
Reputation: 24041
put the -setItemBoundaries
into the -viewWillAppear:
method
- (void)viewDidLoad
{
// [self setItemBoundaries];
}
and:
- (void)viewWillAppear:(BOOL)animated {
[self setItemBoundaries];
}
and violá...
Upvotes: 1
Reputation: 6753
did...
...is called after the rotation has occurred, and therefore possibly after the table has been drawn.
Try,
willRotateFromInterfaceOrientation
...to set the new boundaries before the table is redrawn.
Upvotes: 0