1
votes

I am having Master-Detail template containing UISplitViewController. For plus size Iphone landscape mode, splitviewcontroller automatically splits the view in 2 parts. Left side as Master view controller and right side with detailed viewcontroller.

This scenerio dosen't work with IPhone 5,6,8,X, it works for plus size like IPhone 6+ , 8 + etc.

Below is the code for SplitView delegate method.

func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController:UIViewController, onto primaryViewController:UIViewController) -> Bool 


    guard let secondaryAsNavController = secondaryViewController as? UINavigationController else { return false }
    guard let topAsDetailController = secondaryAsNavController.topViewController as? DetailViewController else { return false }
    if topAsDetailController.selectedEvent == nil {
        // Return true to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded.
        return true
    }
    return false
1

1 Answers

0
votes

Following the documentation, it looks like possible:

In a horizontally regular environment, the split view controller presents its view controllers side-by-side whenever possible. In a horizontally compact environment, the split view controller acts more like a navigation controller, displaying the primary view controller initially and pushing or popping the secondary view controller as needed. You can also ask the split view controller to prefer a specific arrangement by assigning a value to the preferredDisplayMode property.

Try set the preferredDisplayMode to allVisible or primaryOverlay if first one doesn't work.