问题
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
iPhone 5s Portrait when I select location
iPhone 5s Landscape with selected location
iPhone 5s when I rotate from Landscape to Portrait
iPhone 6 Plus Portrait
iPhone 6 Plus Portrait when I select location
iPhone 6 Plus Landscape with selected location
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.
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.
回答1:
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/
来源:https://stackoverflow.com/questions/29767614/why-splitviewcontrollercollapsesecondaryviewcontrollerontoprimaryviewcontrolle