Using classic style of UISplitViewController in Xcode 12

Xcode 12 beta 3 has the following change:

Interface Builder now supports the two-column and three-column styles for UISplitViewController introduced in iOS 14. (57025285)

Which is great is you want to adopt the new Split View Controller API added in iOS 14. However, if you need to support iOS 13 for the time being, it might be easier to keep using the old API instead.

And it looks like since Xcode 12 beta 3, there is no easy way to do that if you use Storyboards.

Any UISplitViewController created with a Storyboard will use either a two column or a triple column style. And because of that there will be significant change in behaviour, new delegate callbacks will be used, etc.

The only workaround that I found so war is to create a UISplitViewController manually, this way it gets the legacy style (UISplitViewControllerStyleUnspecified) and the classic API is used.

Does anyone have a better solution?
I have exactly this issue. Interface Builder has "forced" my split view controller into double width style. When run on iOS 13 it all seems to work, when run on iOS 14 I get problems because it isn't behaving like it used to.

In my app (Adaptivity) I deliberately want to be able to show the user how the Classic style split view controller behaves because it is different. For example, in a double/triple column split view the primary view controller is actually wider than what appears on screen (420 points instead of 320) with a leading margin which is 100 points larger than the trailing margin to cancel out the effect.

It would be really useful if we could select 'Classic' in Interface Builder to keep using the old initialiser.
Could you please create a feedback and mention mine (FB8107534) as well? This way there is a better chance that Apple engineers will notice this and make this improvement.
Yes, that's a big problem!

My app use some split view controllers and they worked properly on Xcode 12 beta 2.
Now on Xcode 12 beta 3 the split view controllers has stopped calling some of its delegate methods.

For example on Xcode beta 2 the delegate method collapseSecondaryOntoPrimaryViewController was correctly called when needed. 

On Xcode beta 3 this method is not called and this message is printed on the output:
[UISplitViewController] Skipping delegate calllback, splitViewController:collapseSecondaryViewController:ontoPrimaryViewController:. Unsupported for UISplitViewController style DoubleColumn

The problem seems to be that now Interface Builder is forcing my split view controllers to have a style of "Two Columns" but if we need to support older version of iOS we need to be able to set the style to "unspecified".

Unfortunately I cannot create the split view controllers programmatically because they are part of a big and complicated storyboard.

I tried to override the style property of UISplitViewController in this way:
Code Block
@available(iOS 14.0, *)
override var style: UISplitViewController.Style {
return .unspecified
}

but without success.

Someone has figured out a way to set the split view controllers style to "unspecified" in the storyboards?

Thank you
My temporary fix is, as Mr. Brightside suggested, to manually instantiate the split view controller and replace the storyboard controller with the new one. If you use the old init() initialiser the style of the controller will be "unspecified" and it will behave in the classic way.

If your split view controller is the root controller of your storyboard you can set it to classic mode in this way:

Code Block
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
...
if #available(iOS 14.0, *) {
if let oldSVC = self.window?.rootViewController as? UISplitViewController {
/* Instantiate an UISplitViewController with the unspecified style (classic mode). */
let newSVC = UISplitViewController()
newSVC.viewControllers = oldSVC.viewControllers
/* Here you can align other properties if needed. */
self.window?.rootViewController = newSVC
}
}
...
}


Hope this helps.

Let's hope that in one of the next Xcode 12 betas it will be possible to set the split view controllers style to "unspecified" (classic mode) directly from the storyboard.
Happy to see that Apple has reported this as a known issue and therefore I expect that it will be solved in one of the next beta.

From Xcode 12 beta 4 release notes:
"Interface Builder doesn’t allow creating a classic style UISplitViewController. (65966010) (FB8107534)"
Using classic style of UISplitViewController in Xcode 12
 
 
Q