NavigationController没有弹出后退按钮

问题描述:

有一个简单的导航控制器(启动基于导航的应用程序项目)我用XIB文件创建了一个新的视图。NavigationController没有弹出后退按钮

HomeViewController(主屏幕上的所有选项UIButton的我:

@implementation HomeViewController 

-(IBAction) optionChoosed:(UIButton *)button 
{ 
    NSString *msg = [NSString stringWithFormat:@"Button: %d", button.tag]; 
    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Hi" message:msg delegate:nil cancelButtonTitle:@"Go away" otherButtonTitles:nil]; 

    switch (button.tag) { 
     case 13: 
      // Simple Search 
      [self loadSimpleSearch]; break; 

     default: 
      [alert show];   
      break; 
    } 
    [alert release]; 
} 

-(void)loadSimpleSearch 
{ 
    SimpleSearchViewController *controller = 
     [[SimpleSearchViewController alloc] initWithNibName:@"SimpleSearchViewController" bundle:nil]; 

    [self.navigationController pushViewController:controller animated:YES]; 
    [controller release]; 
} 

女巫的伟大工程

它推动查看到堆前

!现在,因为在我的第二个视图SimpleSearchViewController我有self.title = @"myTitle";我得到了NavigationBar中的标题以及后退按钮(因为我在HomeViewController上有相同的设置)

我认为NavigationViewController会处理当前视图的弹出窗口,但它不会。

我有什么做,流行的SimpleSearchViewController

我在哪里使用[self.navigationController popViewControllerAnimated:YES];

为视图将继续存在,并ViewDidUnload不会被调用。

我的想法是,这应该是在第一个ViewController,HomeViewController处理,但我不知道什么是我应该钩到的方法,我读了文档,我无法弄清楚: -/

任何帮助,非常感谢,谢谢

HomeViewController

alt text http://cl.ly/XNS/Screen_shot_2010-04-21_at_22.38.51.png

SimpleSearchViewController

alt text http://cl.ly/YDw/Screen_shot_2010-04-21_at_22.40.00.png

SimpleSearchViewController后退按钮

后3210


要从询问是否HomeViewController为根控制器为NavigationViewController

alt text

+0

你可以添加SimpleSearchViewController的代码wh你是否设置了标题? 你是否自己放置后退按钮? – 2010-04-22 07:34:43

+0

不,我不是,这是自动的,你需要做的就是在ViewDidLoad事件中设置标题'self.title = @“Home”;' – balexandre 2010-04-22 08:08:30

+0

你是否将HomeViewController设置为NavigationViewController的根控制器? – 2010-04-22 09:59:43

不知道这是否帮助,但在代码实现navigationItem的时候,如果你不加注释的图像不叫超级弹出功能不会出现

-(UINavigationItem*) navigationItem 
{ 
    UINavigationItem* item = [super navigationItem]; 
    item.title = @"search"; 
    return item; 
}