6

I implemented subclass of UISplitViewController in my app for both: iPhone and iPad. Method mentioned in title is called when I rotate device from Landscape to Portrait orientation. It works really nice unless I run the app on iPhone 6 Plus. Why this method is not called there?

What to do to make this method work?

When I start the app on iPhone 6 Plus everything is fine in both orientations. But the problem is when I rotate iPhone 6 Plus from Landscape to Portrait. My navigation controller is not gonna work as it is expected.

This is what I mean:

iPhone 5s Portrait
enter image description here

iPhone 5s Portrait when I select location

enter image description here

iPhone 5s Landscape with selected location

enter image description here

iPhone 5s when I rotate from Landscape to Portrait

enter image description here

iPhone 6 Plus Portrait

enter image description here

iPhone 6 Plus Portrait when I select location

enter image description here

iPhone 6 Plus Landscape with selected location

enter image description here

iPhone 6 Plus when I rotate from Landscape to Portrait this is a problem because my method splitViewController:collapseSecondaryViewController:ontoPrimaryViewController: is not called. UINavigationController at that time is not working. When I select location nothing happens.

enter image description here

class PBOSplitViewController: UISplitViewController, UISplitViewControllerDelegate {
    override func viewDidLoad() {
        super.viewDidLoad()

        preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible
        delegate = self
    }

    func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController: UIViewController!, ontoPrimaryViewController primaryViewController: UIViewController!) -> Bool {
        return false
    }
}

I setup my SplitViewController in Storyboard.

Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358

1 Answers1

5

iPhone 6+ has a larger screen and in some ways is treated like an iPad. A split view controller on an iPhone 6+ will try to display both master and detail panes similarly as on an iPad, unless the application is in "Zoomed Display Mode".

NSHipster has an article explaining this in greater detail: http://nshipster.com/uisplitviewcontroller/

Nikola Lajic
  • 3,985
  • 28
  • 34
  • I still don't know how to solve the problem. Is it possible to keep the same behaviour on iPhone 6 Plus? – Bartłomiej Semańczyk Apr 21 '15 at 09:35
  • @BartłomiejSemańczyk try forcing the layout you want with UISplitViewControllers `preferredDisplayMode` https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISplitViewController_class/#//apple_ref/occ/instp/UISplitViewController/preferredDisplayMode – Nikola Lajic Apr 21 '15 at 09:42
  • I did this also, but it is still not working properly. I think this is a problem with "Zoomed Display Mode" as you said, but there is no such option in Simulator. – Bartłomiej Semańczyk Apr 21 '15 at 09:48
  • @BartłomiejSemańczyk from your updated answer and your comment it is not clear what is not working and what is expected. Please try to be a little more specific. – Nikola Lajic Apr 21 '15 at 09:50
  • I updated the answer with screenshots. Can you look at? Thank you. – Bartłomiej Semańczyk Apr 21 '15 at 10:06
  • @BartłomiejSemańczyk by default split view controller will only show the side by side view on iPhone 6+ (and tablets), and it will remain in detail view after rotating to portrait mode. So I am guessing this has something to do with your customisations. Post the code you are using to setup and edit the split view controller. – Nikola Lajic Apr 21 '15 at 12:14
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/75813/discussion-between-bartlomiej-semanczyk-and-mrnickbarker). – Bartłomiej Semańczyk Apr 21 '15 at 12:31