Reputation: 38052
I have the following snippet of code:
- (void)loadView {
self.view = [[UILabel alloc] initWithFrame:CGRectMake(20.0, 20.0, 40.0, 40.0)];
self.view.backgroundColor = [UIColor blackColor];
}
If I run the snippet in a project created using the 'view-based application' in the main view controller everything works as expected. However, If I run it in a project created using a 'navigation-based application' the label fills the screen (does not respect the sizes). How can I fix the behaviour for presenting when in a navigation controller? Thanks!
Upvotes: 2
Views: 581
Reputation: 9698
Navigation view controller will resize the view of the view controller to the display area, so the behavior you describe is normal and by-design. Generally, we use empty UIView at the top of hierarchy, and put the subviews inside, which is UILabel in your case.
Upvotes: 1