当我基于存储状态自动跳转到该视图时,为什么工具栏项没有出现?

| 我试图理解为什么为什么在启动并查看存储状态后自动跳转到第二视图(使用UINavigationController)时,工具栏项没有出现? 当我返回主页时(通过UINavigationController标准安排),然后在UITableView中选择该行,并再次回到同一视图,工具栏项看起来很好。 摘录给出的大致思路是: mainController-基于常规选择的条目 通过\“ didSelectRowAtIndexPath \” 创建新的视图控制器并将(pushViewController)推入堆栈 mainController-重新启动并检查以前的状态用户是否在第二层视图中 在viewDidLoad方法的底部检查上一个视图的状态 如果需要,然后按照与上述常规选择方法相同的方法,自动跳至第二层视图-实际上,我将两者的代码重构为为此使用相同的方法/代码 第二层视图 在ViewDidLoad中设置工具栏-此方法中的代码 码:
- (void)setupToolbar {
    [self.navigationController setToolbarHidden:NO];
    UIBarButtonItem *increaseFontButton = [[UIBarButtonItem alloc] 
                                           initWithImage:[UIImage imageNamed:@\"icon_zoom_in.png\"] 
                                           style:UIBarButtonItemStylePlain 
                                           target:self 
                                           action:@selector(pressButtonIncreaseFont:)
                                           ];
    UIBarButtonItem *decreaseFontButton = [[UIBarButtonItem alloc] 
                                           initWithImage:[UIImage imageNamed:@\"icon_zoom_out.png\"] 
                                           style:UIBarButtonItemStylePlain 
                                           target:self 
                                           action:@selector(pressButtonDecreaseFont:)
                                           ];
    NSArray *items = [NSArray arrayWithObjects: increaseFontButton, decreaseFontButton, nil];
    self.toolbarItems = items;

    //release buttons
    [increaseFontButton release];
    [decreaseFontButton release];

}
有任何想法吗?查找故障的想法?     
已邀请:
我发现Objective-C的一个功能非常烦人且容易出错,它是在空对象上调用方法的无提示失败。在setupToolBar方法的第一行之后,请检查navigationController是否为null:
  NSLog(@\" navigationController is 0x%x\", self.navigationController);
是否为重新启动情况创建了navController,与在常规情况下创建方式相同?     
我想出了如何通过消除过程来解决这个问题,但我不明白为什么:) 因此,解决该问题的方法是更改​​应用程序委托的\“ didFinishLaunchingWithOptions \”方法中的以下行:
  // OLD Entry - Did not work
  //[self.window addSubview:navigationController.view];

  // NEW Entry - Fixed it
  self.window.rootViewController = self.navigationController;
有什么想法吗?     

要回复问题请先登录注册