问题
Okay i have a Universal single view application with a UITabbarController as the initial ViewController. i have a UISplitViewController as an item in one of the tabs. the SplitViewController has a navigationController as its master segue, which has a viewController with a uitableView in it and if you click a cell it "shows" the detail view (I've tried the show detail segue also). the splitViewControllers detail view controller segue goes to the detail view controller. my problem is when i go to the tab with the splitViewController in it it shows the detail first and not the master(same for both ipad and iphone). i have spent hours reading and watching different tutorials and looking at questions on here and cant find a solution.
code i have tried(in a custom split viewcontroller class and viewcontroller with the tableView class):
func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController: UIViewController, ontoPrimaryViewController primaryViewController: UIViewController) -> Bool {
return true
}
override func viewWillAppear(animated: Bool) {
splitViewController?.delegate = self
self.splitViewController!.delegate = self;
self.splitViewController!.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible
if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
if let con = self.splitViewController {
con.preferredDisplayMode = .PrimaryOverlay
print("phone")
//^this code doesnt run when i run it on my iphone
}
} else if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
if let spec = self.splitViewController {
spec.preferredDisplayMode = .AllVisible
}
} else {
if let tit = self.splitViewController {
tit.preferredDisplayMode = .Automatic
}
}
}
//controller with tableView class declaration
class OutfitTable : UIViewController, UITableViewDelegate, UITableViewDataSource, UISplitViewControllerDelegate {
//custom splitViewController class declaration
class SplitViewController: UISplitViewController, UISplitViewControllerDelegate
screenshot of main storyboard:
im sorry if this is unnecessarily descriptive i just want to make sure i get all the information out there.
Anything helps. Thank You in advance
来源:https://stackoverflow.com/questions/38277908/uisplitviewcontroller-within-uitabbarcontroller-swift