我正在嘗試使用導航欄(後退按鈕,標題等)和選項卡欄(底部的工具欄)製作應用程序。我正在使用子視圖,所以我不必擔心狀態欄,導航欄,標籤欄高度等。但我認爲這給我造成麻煩,因爲我似乎無法弄清楚如何設置導航欄和製表欄。以編程方式添加導航欄iOS
這是我的。我究竟做錯了什麼?
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
是什麼此代碼的任何有加一個導航欄或工具欄呢?你想添加一個導航欄和工具欄,還是你想要一個導航控制器?你想要完成什麼? – rdelmar
我想這就是我困惑的地方。我想添加一個導航欄和工具欄。但我正在使用子視圖,所以我不確定是否必須做一些不同的事情。 – boxmatic