【发布时间】:2015-07-03 10:46:32
【问题描述】:
我在 iPhone 和 iPad 上制作了一个应用程序。我有UISplitViewController,我在 iPad 上使用它。当我在 iPhone 6 Plus(模拟器)上启动我的应用程序时,UISplitViewController 不起作用。 (在 iPad 3 或 iPad Air 2 和 iPhone 5s 上效果很好)。我在我的代码中添加了以下内容。
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath){
if (UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad) {
performSegueWithIdentifier("showDetailParse", sender: nil)
} else if (UIDevice.currentDevice().userInterfaceIdiom == .Phone) {
performSegueWithIdentifier("showParse", sender: nil)
}
}
我的 iPad 屏幕运行良好
我的 iPhone 6 Plus 屏幕(模拟器)
更新: 我更新了我的代码,它定义了它在哪个设备上工作并且它确实工作了!在代码中,我定义了当前设备的高度,如果大于 2000 像素,我对 iPad 使用 segue。但我不喜欢这个解决方案。有什么想法吗?
我的更新代码如下。
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath){
var screen = UIScreen.mainScreen().currentMode?.size.height
if (UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad) || screen >= 2000 && UIDevice.currentDevice().orientation.isLandscape == true {
performSegueWithIdentifier("showDetailParse", sender: nil)
} else if (UIDevice.currentDevice().userInterfaceIdiom == .Phone) {
performSegueWithIdentifier("showParse", sender: nil)
}
}
【问题讨论】:
标签: swift interface uisplitviewcontroller iphone-6-plus