开发者

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):

  1. Initially set this flag false (in viewDidLoad).
  2. Write pushController code for B in A's viewWillAppear method with checking:

    if(flag)
        push B.
    
  3. When you press the button in modalViewController set this flag and dismiss that.
  4. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜