要求當點擊下面的四個按鈕時彈出新窗口(我用的push),但是push出來的默認帶leftitem返回嘛,可是我的不帶。不知道是不是viewcontroller寫的邏輯問題。
我是把rootviewcontroller設置成UINavigationController,appdelegate代碼如下
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
//1、創建窗口
self.window = [[UIWindow alloc] init];
self.window.frame = [UIScreen mainScreen].bounds;
//2、設置根視圖
UINavigationController *nac = [[UINavigationController alloc] init];
self.window.rootViewController = nac;
nac.view.backgroundColor = [UIColor redColor];
HLhomeViewController *homeView = [[HLhomeViewController alloc] init];
//homeView.view.backgroundColor = [UIColor whiteColor];
[nac addChildViewController:homeView];
nac.navigationBar.translucent = NO;
nac.navigationBar.barStyle = UIBarStyleBlack;
homeView.navigationItem.title = @"ee";
[self.window addSubview:homeView.view];
appdelegate裡面控制器設置的先後順序不能變。UINavigationController是比較底層的控制器。
HLhomeViewController *homeView = [[HLhomeViewController alloc] init];
UINavigationController *nac = [[UINavigationController alloc] initWithRootViewController:homeView];
self.window.rootViewController = nac;
接下來設置標題,在HLhomeViewController裡面,self.title設置就行。
接下來點擊按鈕push: [self.navigationController pushViewController:controller animated:YES]