简体   繁体   中英

UINavigationController back and close button

I have a navigation controller. The controller works well and shows me the back button for go back to the window. But when I add this code for add the close button:

- (void)viewDidLoad 
{
  [super viewDidLoad];

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

}

...then the back button disappears, and I can only see the close button. Why?

THE PROBLEM was in

 dismissModalViewControllerAnimated 

I HAD TO USE

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM