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 picture)
Does anyone know how i can fixed this problem under iOS 13? On iOS 12 everything works like a charm ☹️
Thx in advance Sebastian
Edit:
Sorry for the late answer I was on a short holiday trip without any internet :/
my Class looks like this:
class MyClass : UITableViewController, UISplitViewControllerDelegate, UIPickerViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
if (UIDevice.current.userInterfaceIdiom == .pad){
navigationController?.navigationBar.isTranslucent = false
}
/*SplitView*/
splitViewController?.preferredDisplayMode = .allVisible
splitViewController?.delegate = self
self.definesPresentationContext = true
}
// SplitView
func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController: UIViewController, onto primaryViewController: UIViewController) -> Bool {
return true
}
}
I think it's look like the normal procedure for this problem :/
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():
Now the
splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController: UIViewController, onto primaryViewController: UIViewController) -> Bool
is called, and if you return true, the master will be displayed.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!