按导航栏按钮时如何进入主屏幕

时间:2011-01-19 09:54:12

标签: iphone

我想在导航栏上添加一个右键按钮作为主页按钮..

当我点击那个按钮时,我想去第一个控制器,这是我的主屏幕

请帮助我

提前致谢

2 个答案:

答案 0 :(得分:2)

使用此按钮进入导航栏中的主屏幕,首先创建右侧栏按钮

{
    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];
}

答案 1 :(得分:1)

如果您的应用程序是基于导航的应用程序,那么请在按钮的IBAction中使用以下代码行。

[self.navigationController popToRootViewControllerAnimated:YES];
相关问题