Use case for push versus modal segues?

陌路散爱 提交于 2019-12-05 01:56:23

If you want to follow Apple's best practices, I would suggest the following :

  1. For the "Add" functionality, use a modal segue.
    For example look at the contacts app. Pressing + shows a modal view controller.
    What's the logic ? for start, modal view controllers usually have a "cancel" button, as opposed to the "back" button on a pushed vc.
    When the user presses "back" - he'd expect a way to come back to the vc. Usually "back" saves your data on iOS (auto-saved).
    So by using a modal segue you force the user to submit the form , or cancel. The modal presentation hints that you really need to fill this screen.

  2. For editing - push. but modal could work as well (and you could reuse the same VC).
    Reasons for push :

    • you get a hierarchy of vc's , going back and forward while drilling down.
    • (you should implement) auto saving when going back (just like other iOS apps)

I hope this quick summary will help you : When you want to show a detail view of a summary view, use a navigation controller and Push Segues. If the "parent" view doesn't really relate as far as data is concerned to the "child" view, then use a modal. A good example for a modal view would be any entry view. This view doesn't really have any relationship as far as data is concerned to the "parent" view., the entry screen will just take data dat from user & will save & can go away & giving control back to parent

For adding a new entity to the core data table, on tapping the + button (I assume its a right bar bar button item on the navigation bar), use the modal segue. The view for adding a new row for the enity has to be presented modally and once the save is completed, dismiss the modal view and reload the table view to display the newly added item.

Also for displaying the details of an entity row, use the push segue. A user expects a push action when he selects a table cell and it is the ideal way to do that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!