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 ]; 
相关问题