2011-01-19 72 views

回答

2

使用这个去主屏幕导航栏中,首先创建rightBar按钮

{ 
    UIBarButtonItem *Button = [[UIBarButtonItem alloc] 
            initWithTitle:@"Home" 
            style:UIBarButtonItemStylePlain 
            target:self 
            action:@selector(Button_Action)]; 
    self.navigationItem.rightBarButtonItem = Button; 
    [Button release]; 
} 

-(void) Button_Action 
{ 
    [self.navigationController popToRootViewControllerAnimated:YES]; 
} 
+0

感谢您的回应....我创建了另一个自定义视图,并将该视图放置在我的导航栏上,所以现在我将该按钮添加到该视图。现在,我可以转到我想要的控制器,当我点击那个按钮 – ask123 2011-01-19 10:29:59

1

如果你的应用程序是基于应用程序,然后使用代码下面一行在你的按钮的IBAction为导航。

[self.navigationController popToRootViewControllerAnimated:YES];