Elvis Oliveira
Elvis Oliveira

Reputation: 949

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"

enter image description here

They will be redirect to this page:

enter image description here

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

Upvotes: 0

Views: 778

Answers (1)

Ben-G
Ben-G

Reputation: 5026

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.

Upvotes: 2

Related Questions