I have an app where there is a UISplitViewController with a navigation controller, itself bound to a UITableViewController displaying a menu to navigate. There is no Detail View Controller being bound, as there is nothing I want to display as a default.
On my physical devices, my code behaves the way I expect it: on iPhone/iPad I can use the UITableViewController and bind my cells to the other UIViewControllers with a Show Detail segue.
On emulator, the same code displays a gray screen in between, as if the Display View Controller were being shown in between, and it does this every single time I perform a Show Detail segue. This is very confusing and I honestly don't know where the bug comes from.
Here is a video that shows the behaviour: https://youtu.be/ygx6kiHux-8
And here are some snippets:
LoginSegue.swift
import UIKit
class LoginSegue: UIStoryboardSegue {
override func perform() {
UIApplication.shared.keyWindow?.rootViewController = self.destination
}
}
And CustomSplitViewController.swift:
class CustomSplitViewController: UISplitViewController, UISplitViewControllerDelegate {
var user: User? = nil
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
if let mainViewController = masterViewController?.topViewController as? MainViewController {
mainViewController.user = user
}
// Do any additional setup after loading the view.
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if var signedInViewController = segue.destination as? SignedInViewController {
signedInViewController.user = self.user
} else if var mainViewController = segue.destination as? MainViewController {
mainViewController.user = self.user
}
}
// This method is never called, and I don't know why.
func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController: UIViewController!, ontoPrimaryViewController primaryViewController: UIViewController!) -> Bool{
return true
}
}
My MainViewController is the UITableViewController you can see on the video.
Thank you in advance.