iOS 13 UISplitView Problems

后端 未结 8 1206
情话喂你
情话喂你 2021-01-02 14:00

On iOS 13 Beta 5, I currently have problems with my UISplitView on iPhones.

My app starts with the detailsview off my splitview not with my masterview (look at the p

相关标签:
8条回答
  • 2021-01-02 14:10

    did you try this one (UISplitViewControllerDelegate):

    self.preferredDisplayMode = .allVisible
    

    &

    func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController: UIViewController, onto primaryViewController: UIViewController) -> Bool {
        return true;
    }
    
    0 讨论(0)
  • 2021-01-02 14:10

    Try MasterViewController_Instance.view.layoutIfNeeded() inside Splitviewcontroller ViewDidLoad() method. It fixed my problem.

    class CustomSplitController: UISplitViewController{ 
        override public func viewDidLoad() {
    
            MASTER_CONTROLLER_INSTANCE.view.layoutIfNeeded()
            //If you are using navigation controller in master controller try 
            MASTER_CONTROLLER_INSTANCE.navigationController?.view.layoutIfNeeded()
        }
    }
    
    0 讨论(0)
  • 2021-01-02 14:12

    Alxlives's answer helped me. By using the debugger, I notice that in the master view controller, viewDidLoad is not called. So the delegate is never set, thus the collapse method is never called.

    I fixed this by setting the delegate in awakeFromNib():

    override func awakeFromNib() {
        self.splitViewController?.delegate = self
    }
    

    Now the splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController: UIViewController, onto primaryViewController: UIViewController) -> Bool is called, and if you return true, the master will be displayed.

    0 讨论(0)
  • 2021-01-02 14:14

    For those who use storyboard and configure the new controller in a subclass from UIStoryboardSegue, it'll be simpler:

    just before [source presentViewController:destination animated:YES completion:nil];, just set destination.modalPresentationStyle = UIModalPresentationFullScreen;, because the default is now UIModalPresentationPageSheet.

    0 讨论(0)
  • 2021-01-02 14:20

    I set the spliteViewController's delegate on appdelegate, and it worked

    0 讨论(0)
  • 2021-01-02 14:29

    As many answers here leads to change in the Split View Controller starting sequence, I realized, that on compact size it performs vewDidLoad on detail controller ONLY. But awakeFromNib is called on every controller. So - I've just transfer my code from viewDidLoad to awakeFromNib and everything now is works perfectly!

    override func awakeFromNib() {
        super.awakeFromNib()
    
        if let splitController = splitViewController {
            splitController.delegate = self
        }
    }
    
    0 讨论(0)
提交回复
热议问题