How to use a UISplitViewController in Swift
You are so close just do the following.
Keep the split view layout with detail segues and return true for the following method and remove the rest of the code to do with the variable collapseDetailViewController
.
func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController: UIViewController, ontoPrimaryViewController primaryViewController: UIViewController) -> Bool {
return true
}
Put the following in you Master View controller
self.splitViewController!.delegate = self;
self.splitViewController!.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible
self.extendedLayoutIncludesOpaqueBars = true
Add self.extendedLayoutIncludesOpaqueBars = true
to your detail view controller as mentioned by the previous answer. That should remove the bar appearing on your view controllers.
Also if you want some extra functionality add the following if you want your detail view to use the full screen on iPad.
navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem()
navigationItem.leftItemsSupplementBackButton = true
How to create UISplitViewController programmatically in Swift
if you want do it with navigationController, then try it:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
if UIDevice.current.userInterfaceIdiom == .pad {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window!.backgroundColor = UIColor.whiteColor()
var splitViewController = UISplitViewController()
var homeViewController = HomeViewController()
var secondViewController = SecondViewController()
var homeNavigationController = UINavigationController(rootViewController:homeViewController)
var secondNavigationController = UINavigationController(rootViewController:secondViewController)
splitViewController.viewControllers = [homeNavigationController,secondNavigationController]
self.window!.rootViewController = splitViewController
self.window!.makeKeyAndVisible()
return true
} else {
// use single controller for iPhone and return that controller
}
}
Related Topics
Why Doesn't iOS System Sound Play in Simulator
Navigation with Only Back Button and Transparent Background
How to Completely Reload a View So That Viewdidload Gets Run Again
Giving Properties of a Uibutton to a Skspritenode in Spritekit
How to Display Cgpdfdocument in Swift
How to Remove the Black Border of a Textfield
Timer Label Not Updated After Switching Views (Swift)
Finding It Difficult to Pass Data to Separate Viewcontroller
Buttonwithtype' Is Unavailable: Use Object Construction 'Uibutton(Type:)
Alamofireimage Disk Cache Not Working
Setting a Stateobject Value from Child View Causes Navigationview to Pop All Views
Swift Universal Framework Depending on Pod
How to Get the Today's and Tomorrow's Date in Swift 4
How to Make an API Call When the User Terminates the App
How to Get All the Sundays in Array of Date iOS
Swipe to Delete on a Tableview That Is Inside a Pageviewcontroller