'Show' segue in Xcode 6 presents the viewcontroller as a modal in iOS 7

后端 未结 11 430
离开以前
离开以前 2021-01-01 10:11

I have two view controllers in my iPhone application (built with swift) built with Xcode 6.1 and uses storyboards.

The first view controller is embedded in a navigat

相关标签:
11条回答
  • 2021-01-01 10:58

    Basically the answer of Jomafer is partly correct. The controller which you are pushing needs to be preceded by a UINavigationController. You dont really need to push the UINavigationController at all. As long the storyboard knows its within a UINavigationController, all is well.

    0 讨论(0)
  • 2021-01-01 11:00

    When a "Show" segue comes up as a modal segue in testing it is usually one of two problems:

    1. The first view controller is not inside a navigation controller.

    2. The storyboard XML is corrupted.

    The solution to #2 is usually to remove and replace the segue, and it should correct itself. Sometimes just switching to some other presentation style, running, and switching back to "Show" fixes it.

    This can also happen to "Show Detail" segues, and it can be more insidious.

    Example: I have a series of view controllers arranged in a UISplitViewController. They have segues Show->Show->Show->Show Detail. The last segue kept coming up modal. I tried everything to fix that last segue. The problem was that the upstream Show segue had been corrupted into a Show Detail segue (even though the storyboard still said it was a Show segue). I had been testing on iPhone, and I did not discover the real problem until I ran it on the iPad simulator. The segues were now Show->Show->Show Detail->Show Detail. On the iPhone the third segue looked just like a Show because it collapsed onto the navigation controller. However, it is still the detail view controller, and you cannot have a Show Detail from a detail view controller, so the OS does what it can to get your view controller on screen and displays it modally.

    Lesson 1: Always test your UISplitViewController on iPad to make sure the segues are doing what you think.

    Lesson 2: If your segue is coming up modal unexpectedly, check the upstream segues for corruption as well as the segue in question.

    0 讨论(0)
  • 2021-01-01 11:05

    It's possible that you have assigned the Initial View Controller to your UIViewController instead of the UINavigationController. Also, select your UIViewController and check that the "Is Initial View Controller" option is unchecked.

    Set the UINavigationController as the Initial View Controller

    0 讨论(0)
  • 2021-01-01 11:13

    I believe this is a bug in Xcode 7.2. In order to workaround, you can create a "Push (deprecated)" segue and then in the Storyboard editor, select the segue and change it to Show(e.g. Push)

    0 讨论(0)
  • 2021-01-01 11:14

    I have had this exact issue with "Show (eg. Push)" for ages and I have just figured it out whilst trying to push a view controller onto a navigation controller that is in a Popover. It seems that the context of the called View Controller is the problem. So this is how I resolved it:

    1. On the View Controller performing the Segue, check the "Defines Context" property in the Storyboard.
    2. In the called View Controller, set the Presentation property to "Current Context".
    0 讨论(0)
提交回复
热议问题