Transition from modal view to next view controller in modal's parent
I have MyViewControllerA which was pushed into view by a navigation controller. MyViewControllerA displays MyModalViewController. MyModalViewCon开发者_如何学运维troller has a button where once pressed will push MyViewControllerB ontop of MyViewControllerA. I created a delegate so MyModalViewController can tell MyViewControllerA that a button was a pressed so MyViewControllerA can place MyViewControllerB ontop of it.
Is there a clean way to transition from MyModalViewController to MyViewControllerB. I tried to dismiss the modal view after pushing MyViewControllerB, but it does not give me that smooth animation when you normally drill down with a nav controller.
As you said you have delegate that can tell ControllerA
about the button press. Now what you have to do is have a flag in ControllerA
(which will we use to tell A about the button press):
- Initially set this flag false (in
viewDidLoad
). Write
pushController
code for B in A'sviewWillAppear
method with checking:if(flag) push B.
- When you press the button in
modalViewController
set this flag and dismiss that. - When this view will be dismissed then your
viewWillAppear
method will be called and it will push B if flag is set.
If still animation is not smooth then please use viewDidAppear
method rather than viewWillAppear
.
Thanks.
精彩评论