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

后端 未结 11 547
离开以前
离开以前 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 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.

提交回复
热议问题