In my UIKit App i am using a UISplitViewController()
as my rootViewController. I configure it in my SceneDelegate
like this:
var splitView: UISplitViewController?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
self.makeSplitViewController()
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = self.splitView
self.window = window
window.makeKeyAndVisible()
self.splitView?.viewController(for: .secondary)?.navigationController?.navigationBar.barStyle = .black
}
}
func makeSplitViewController() {
let splitViewController = UISplitViewController(style: .doubleColumn)
splitViewController.preferredDisplayMode = .oneBesideSecondary
let primaryViewController = UINavigationController(rootViewController: CalendarViewController())
let secondaryViewController = UIHostingController(rootView: EventDetailView())
splitViewController.setViewController(primaryViewController, for: .primary)
splitViewController.setViewController(secondaryViewController, for: .secondary)
splitViewController.setViewController(primaryViewController, for: .compact)
self.splitView = splitViewController
}
As you can see, i am using the CalendarViewController
(wrapped inside a UINavigationController) as my primaryViewController and for the secondary view i am using a SwiftUI View, wrapped in a UIHostingController
The result looks like this:
As you can see, the CalendarViewController fits the iPhone Screen but not the iPad Primary Column. The CalendarViewController
comes from CalendarKit, a Swift Calendar Library.
What do i need to change in the CalendarViewController to fit the SplitView Primary Column? Any ideas?
Reference: CalendarViewController