iOS - pushViewController vs presentModalViewController difference

前端 未结 5 812
南旧
南旧 2021-02-01 17:17

What is the difference beetween calling presentModalViewController and pushViewController, when :

  • animation is set to NO (even if yes, th
5条回答
  •  有刺的猬
    2021-02-01 17:55

    The most important difference is about semantics. Modal view controllers typically indicate that the user has to provide some information or do something. This link explains it more in depth: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html

    Here's another, less abstract difference they talk about:

    "When you present a modal view controller, the system creates a parent-child relationship between the view controller that did the presenting and the view controller that was presented. Specifically, the view controller that did the presenting updates its modalViewController property to point to its presented (child) view controller. Similarly, the presented view controller updates its parentViewController property to point back to the view controller that presented it."

    Also see this thread: why "present modal view controller"?

提交回复
热议问题