0

我有一個UINavigationController,它具有UITableViewController,因爲它是根視圖。 UINavigationController位於UITabBarController之內。導航控制器中的UITabBarController中的UINavigationController具有多個視圖

在的UITableViewController(* viewOne),如果我點擊一個電池單元的下面的代碼運行

UIViewController *newView = [[UIViewController alloc] initWithNibName:@"newView" bundle:nil]; 
[self.navigationController pushViewController:newView animated:YES]; 
[newView release]; 

然後,NewView的內部是:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { 

     NSLog(@"%@", self.navigationController); 

    } 
    return self; 
} 

日誌有:

[8947:207] (null) 

如果我嘗試將新的視圖控制器推送到navigationController,則什麼都不會發生。任何線索?

回答

0

我已經想通了。

在我的應用程序委託,我添加了一個新的屬性:

UINavigationController *profileNavigationController; 
@property (nonatomic, retain) IBOutlet UINavigationController *profileNavigationController; 

而在IB,我從應用程序的委託到導航控制器連接profileNavigationController。

而現在,推新觀點的時候,我打電話:

StartDateSelectorViewController *startDateSelectorViewController = [[StartDateSelectorViewController alloc] initWithNibName:@"StartDateSelectorView" bundle:nil]; 

Strength_EngineAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; 
[delegate.profileNavigationController pushViewController:startDateSelectorViewController animated:YES ]; 
相關問題