UISplitViewController: Deinit DetailView in Folded Mode

I’ve been fighting for this for some time, but I couldn’t find a solution:

I have an iOS 9 application that supports all device families, uses size classes, and is programmed with Swift 2.0. I use UISplitViewController, and everything works the way I want, except for a minimized environment (for example, on the iPhone).

The Master-ViewController is the UITableViewControllerone that triggers the replacement of segue when selecting a cell. In a minimized environment, this means that the detailViewcontroller element hits the screen. UISplitViewControllervisually behaves like a UINavigationController. However, when I reject the detailViewController using the back or gesture button, it is not released until the new segue shift in the Master-ViewController is canceled.

I suppose this is a kind of function UISplitViewControllersince it was originally designed to display both contents side by side. However, in a folded environment, I would like mine UISplitViewControllerto behave as a simple UINavigationControllerone that releases the previously thrown detailviewController when it appears.

I try to manually change the splitViewController attribute viewControllersafter the detailViewController element appears:

 if let firstVc = self.splitViewController?.viewControllers.first {
        self.splitViewController?.viewControllers = [firstVc]
 }

But that does not help. Simply replacing detailViewController with an empty "Dummy" -ViewController does not work either, since it automatically enlivens the transition. Playing with UISplitViewControllerDelegatedidn't help me ...

Is there a solution for this (maybe just? :)) that I'm too blind to see?

+4

Source: https://habr.com/ru/post/1612438/


All Articles