UISplitViewController within UITabbarController Swift

跟風遠走 提交于 2019-12-12 03:37:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!