UINavigationController后退和关闭按钮

时间:2012-05-26 16:39:50

标签: iphone objective-c ios uinavigationcontroller

大家好我有一个导航控制器, 控制器工作正常,并显示返回窗口的后退按钮 但是当我添加这个代码来添加关闭按钮时:

- (void)viewDidLoad 
{
  [super viewDidLoad];

  UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Chiudi" 
                                  style:UIBarButtonItemStylePlain target:self
                       action:@selector(dismissModalViewControllerAnimated:)];          

  self.navigationItem.rightBarButtonItem = doneButton;

  [doneButton release];

}

后退按钮消失,我只能看到关闭按钮 为什么?

1 个答案:

答案 0 :(得分:2)

问题在于

 dismissModalViewControllerAnimated 

我必须使用

 [self.navigationController dismissModalViewControllerAnimated:YES];     
 [self.navigationController popToRootViewControllerAnimated:NO];