How to dismiss a view controller opened with presentModalViewController:

前端 未结 3 696
迷失自我
迷失自我 2021-02-05 10:25

I presented a view controller using presentModalViewController:, now how to close/dismiss it?

相关标签:
3条回答
  • 2021-02-05 10:57

    For iOS6 use this code

    [self dismissViewControllerAnimated:YES completion:Nil];
    

    instead of

    [self dismissModalViewControllerAnimated:YES];
    

    This may help you.

    0 讨论(0)
  • 2021-02-05 11:03

    You have two choices, both involves using dismissModalViewController.

    The preferred way is to use delegation and tell the view controller who was responsible for presenting the view to dismiss it. The other way is to have the view who was presented to dismiss itself (which actually asks the parent to dismiss it.)

    0 讨论(0)
  • 2021-02-05 11:08

    From the controller presented modally:

    [self dismissModalViewControllerAnimated:YES]
    
    0 讨论(0)
提交回复
热议问题