##概要
UISplitViewController の MasterView に UITabBarController を追加した所、iPhone でUITableViewController のセルをクリックして DetailView への遷移がプッシュではなくモーダルで表示されてしまうので解決方法のメモです。
##下記コードを AppDelegate.swift へ追加
func splitViewController(splitViewController: UISplitViewController, showDetailViewController vc: UIViewController, sender: AnyObject?) -> Bool {
if splitViewController.collapsed {
let primaryTab = splitViewController.viewControllers.first as! UITabBarController
let primaryNavi = primaryTab.selectedViewController as! UINavigationController
let detailNavi = vc as! UINavigationController
if let detail = detailNavi.topViewController {
primaryNavi.pushViewController(detail, animated: true)
}
return true
} else {
return false
}
}
func splitViewController(splitViewController: UISplitViewController, separateSecondaryViewControllerFromPrimaryViewController primaryViewController: UIViewController) -> UIViewController? {
let primaryTab = splitViewController.viewControllers.first as! UITabBarController
let primaryNavi = primaryTab.selectedViewController as! UINavigationController
if primaryNavi.viewControllers.count > 1 {
return primaryNavi.popViewControllerAnimated(false)
} else {
return nil
}
}