I was able to get something working using UISplitViewControllerDelegate and including the function below. You'll also need to set splitViewController?.presentsWithGesture = false to disable the automatic button assignment
func splitViewController(_ svc: UISplitViewController, willChangeTo displayMode: UISplitViewController.DisplayMode) {
let pvc = (svc.viewController(for: .secondary) as? UINavigationController)?.topViewController
if let addButton = self.addButton, let backtimeButton = self.backtimeButton, let sidebarButton = self.sidebarButton, let sidebarButtonOn = self.sidebarButtonOn {
switch displayMode {
case .oneBesideSecondary, .oneOverSecondary:
pvc?.navigationItem.setLeftBarButtonItems([], animated: true)
navigationItem.setLeftBarButtonItems([addButton, backtimeButton, sidebarButtonOn], animated: true)
default:
pvc?.navigationItem.setLeftBarButtonItems([addButton, backtimeButton, sidebarButton], animated: true)
navigationItem.setLeftBarButtonItems([], animated: true)
}
}
}
This does not animate as nicely as the Calendar app, I too would be curious how the official solution is implemented. The toggle button they use to show/hide the sidebar is also somewhat challenging to reproduce as the UIBarButtonItem doesn't have the option to set as selected like a standard UIButton. This solution does at least seem to transfer the buttons to the sidebar when appropriate like the calendar app.
Post
Replies
Boosts
Views
Activity
I submitted a bug report for this and have the same issue on Beta 3 but not Beta 2. It appears to be inappropriately setting the horizontal trait collection to compact if a UISplitViewController is inside a UITabBarController. In fact if you override the getter for the traitCollection (which you're not technically supposed to do) on the splitviewcontroller and pass the parent traitCollection from the tabbarcontroller most of the problems go away aside from a few visual glitches with navigation bar title positioning.
Issue persists on beta 4 and the workaround still works. The navigation bar positioning bug was fixed however.
This appears to be fixed in XCode 12 beta 5
They restored an option for Style: "Unspecified (Discouraged)" in storyboard for UISplitViewController which reverts things back to the previous behavior. You'll need to rebuild the storyboard with the new version for this to take effect (simply rebuilding the project but never opening the storyboard will not work).
I was able to force this on the simulator by modifying the .GlobalPreferences.plist file
If you navigate to your simulator directory
~/Library/Developer/CoreSimulator/Devices/<SIMULATORID>/data/Library/Preferences/
There is a hidden file named .GlobalPreferences.plist
Make a backup of this file and convert it to XML
$ cd ~/Library/Developer/CoreSimulator/Devices/<SIMULATORID>/data/Library/Preferences/
$ cp ./.GlobalPreferences.plist ./.GlobalPreferences.plist.orig
$ plutil -convert xml1 ./.GlobalPreferences.plist
The file should look something like this
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AppleLanguages</key>
<array>
<string>en</string>
</array>
<key>AppleLocale</key>
<string>en_US</string>
</dict>
</plist>
Add the following inside the <dict></dict> section
<key>SBChamoisWindowingEnabled</key>
<true/>
Then convert back to binary
$ plutil -convert binary1 ./.GlobalPreferences.plist
Now start your simulator and Stage Manager should be enabled
Worked for me on Beta 3 iPad 11 3rd gen sim
Credit goes to
https://twitter.com/KhaosT/status/1533928828753481729
https://itnext.io/you-dont-need-gui-or-how-to-control-ios-simulator-from-command-line-bf5cfa60aed2
https://developer.apple.com/forums/thread/708567?answerId=720569022#720569022
Posted an option here