I have a navigation-based application which uses a navigation bar and a navigation stack to which custom UIViewControllers are pushed. The problem is that when a new UIViewController is allocated, initialized and finally pushed to the stack, the height of this controller's view does not fit to the screen. I mean, for example an y-position
self.view.frame.size.height - 10 is drawn offscreen. It seems that the size of the my controller's view does not take account the navigation bar.
I tried using autoresizing mask in viewDidLoad and loadView but nothing seems to work. Any help would be appreciated.
This is the pushing action called when a user hits a button:
Code:
NaviAppDelegate *appDelegate = (NaviAppDelegate *)[[UIApplication sharedApplication] delegate];
UINavigationController *navigationController = appDelegate.navigationController;
MyGameViewController *aViewController = [[MyGameViewController alloc] init];
[navigationController pushViewController:aViewController animated:YES];
and in MyGameViewController.m i have:
Code:
- (void)loadView {
[super loadView];
self.view.autoresizesSubviews = YES;
self.view.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
}
- (void)viewDidLoad {
[super viewDidLoad];
int f = 10;
self.graphView = [[UIView alloc] initWithFrame:CGRectMake(f,f,self.view.frame.size.width-2*f, self.view.frame.size.height-2*f)];
graphView.backgroundColor = [UIColor blueColor];
[self.view addSubview:graphView];
}
The viewDidLoad method should create a blue rectangle drawn to the screen with margins of 10px in each direction. But the margins appear only on the upper, left and right directions... bottom does not have any margin.