Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 navigation controller in the storyboard and the segue for the second view controller is a 'Show' segue.

When the application is run, it properly shows the transition as a push in iOS 8.x, but in iOS 7.x it appears as a modal without the navigation bar.

My application requirement is to show the transition as a push regardless of whether it's iOS 7 or iOS 8. Any ideas to get this working as push in both versions of the iOS?

I saw a related post where this issue is mentioned, but could not find a solution to the problem: Adaptive segue in storyboard Xcode 6. Is push deprecated?

Any help is appreciated...

Thanks

like image 663
momentsnapper Avatar asked Oct 30 '14 09:10

momentsnapper


People also ask

How do I add segue to iOS?

To create a segue between view controllers in the same storyboard file, Control-click an appropriate element in the first view controller and drag to the target view controller. The starting point of a segue must be a view or object with a defined action, such as a control, bar button item, or gesture recognizer.

How do I set the identifier for ViewController in storyboard?

Step 1: Set a Storyboard IDIn the Storyboard, select the view controller that you want to instantiate in code. Make sure the yellow circle is highlighted, and click on the Identity Inspector. Set the custom class as well as the field called "Storyboard ID". You can use the class name as the Storyboard ID.


2 Answers

This solution is different from the others in the following ways:

  1. It includes a method to examine and verify the issue
  2. The cause of the issue is traced to the source (a change in the segue type)
  3. The solution is very simple (delete and recreate a new segue)
  4. Please note the requirements in the text

I just gave a very detailed SO answer that fully explains what is happening and why, but the simple solution is you can delete the Segue that is not pushing and then recreate it on the storyboard. The reason is that there is likely a broken bit of xml in the segue (see extended answer for example/instructions how to confirm this issue).

After you confirm that you have at least one UINavigationController within the view hierarchy, be sure that the segue is NOT a manual segue and does NOT have an action associated with it (by viewing the segue in the storyboard as Source Code). Delete the existing segue and then Ctrl-drag from a UIView/UIControl to the target view controller and if custom action is needed intercept the call to destination controller in prepareForSegue.

Also to confirm that this solution works for you please do the following:

  • Verify that your initial view controller (with the arrow on it) is a UINavigationController and that it has a normal content view controller as it's root view controller. (or that you embed your initial view controller inside of a UINavigationController)
  • Read my extended comments on an earlier response to a very similar question (linked above).
like image 146
Tommie C. Avatar answered Oct 04 '22 20:10

Tommie C.


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

like image 29
jomafer Avatar answered Oct 04 '22 20:10

jomafer