I am trying to make an App with a Navigation Bar (Back button, title, etc) and a Tab Bar (Toolbar on the bottom). I am using subviews so I don't have to worry about the status bar, navigation bar, tab bar heights, etc. But I think it's causing me trouble because I can't seem to figure out how to setup the Nav and Tab Bars.
Here is what I have. What am I doing wrong?
AppDelegate.h
(default for single view app)
AppDelegate.m
(default for single view app)
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) UIView *contentSubview;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)loadView{}
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *view = [[UIView alloc] init];
view.backgroundColor = [UIColor greenColor];
self.contentSubview = [[UIView alloc] init];
self.contentSubview.backgroundColor = [UIColor orangeColor];
[view addSubview:self.contentSubview];
self.view = view;
}
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
self.contentSubview.frame = CGRectMake(
0,
self.topLayoutGuide.length,
CGRectGetWidth(self.view.frame),
CGRectGetHeight(self.view.frame)-self.topLayoutGuide.length-self.bottomLayoutGuide.length
);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
See Question&Answers more detail:os