Aaron Bratcher
Aaron Bratcher

Reputation: 6471

Pushed segue scene works, modal segue scene doesn't?

I am manually calling a push segue which works great. The new TableView scene comes up, the custom nav buttons in the nav controller work perfect.

However, I want it to be a modal segue instead. So, I changed the type to Modal and embedded the new scene in a Navigation Controller. The new scene comes up, however the scene won't go away when the cancel button is tapped.

Any ideas why? Thanks.

Upvotes: 0

Views: 234

Answers (1)

jere
jere

Reputation: 4304

A Push segue adds a new view controller to the navigation stack in which the presenting view controller is also contained. That's why the navigation bar works in that case.

A Modal segue doesn't add the view controller to the navigation stack, it adds it as a child of the presenting view controller, so in this case there is no defined navigation.

If you want your nav bar to work on the modally presented controller you are going to have to wire up the actions manually (e.g.: make the "Back" button dismiss the modally presented controller).

Also, as pointed out by @Edwin Iskandar, make sure you call the proper dismiss actions on the view controller, meaning: popViewControllerAnimated won't work on a modally presented view controller, instead you should call dismissModalViewControllerAnimated

P.S.: Note that dismissModalViewControllerAnimated is deprecated in favor of dismissViewControllerAnimated:(BOOL) completion:^(void)completion for iOS 6

Upvotes: 1

Related Questions