简体   繁体   中英

iOS - navigation controller back button

I'm developing an iPad App using storyboards. In this app when the user click on "preferences" appear a modal View. One button of this view send the user to another View Controller (but this view has an action bar to go back to his root view controller), but when user taps the action bar back button nothing happen (it's called navigationController popViewControllerAnimated), the user continue in the same view.

Can anyone help me??

Thanks.

UPDATE:

The code to handle the back button:

- (IBAction)btnBackTapped:(id)sender {
   [self.navigationController popViewControllerAnimated:YES];
}

I'm using Segue (from storyboard) to call this View Controller:

When the user click on "Meus Favoritos"

在此处输入图片说明

They will be redirect to this page:

在此处输入图片说明

The segue is with a Modal (from image one to two)...

When you are presenting a View Controller modally, it is likely not within a Navigation Controller, so probably the reference to navigationController in your code is nil , can you check that?

If you are presenting your View Controller modally this will work instead

[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];

However, if you actually want to use a Navigation Controller, you should embed the View Controller that is presenting the Preferences View Controller in a Navigation Controller and present the Preferences View Controller with a show segue instead of a modal one.

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