程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> ios-關於添加UINavigationController

ios-關於添加UINavigationController

編輯:編程綜合問答
關於添加UINavigationController

如果給UIViewController添加作為modal的UINavigationController。

有一個flow,在firstViewController中開始,然後在view中調用secondViewController

- (IBAction)PressButton:(id)sender {

    SecondViewController *second = [[SecondViewController alloc] init];
    second.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    UINavigationController *nav = self.navigationController;
    [nav presentViewController:second animated:YES completion:nil];                              
}

在secondViewController 中希望能推進thirdViewController,但是沒有用,我用了下面的方法嘗試:

- (IBAction)pressButton:(id)sender {

   ThirdViewController *tvc = [[ThirdViewController alloc] init];
   UINavigationController *nav = self.navigationController;
   [nav pushViewController:tvc animated:YES];
}

點擊 secondViewController 時完全沒有反應。

請高手指點一下哪裡出錯了,謝謝
我用的:
OSX 10.8.2
Xcode 4.6
iOS 6.1

最佳回答:


將第二個view作為導航控制器的root,同時從所屬的view中調用當前ViewController

- (IBAction)PressButton:(id)sender {
        SecondViewController *second = [[SecondViewController alloc] init];
        second.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:second];
        [self presentViewController:navigationController animated:YES completion:nil];    
    }
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved