首页 > 解决方案 > pushViewController 仅在 iPad 上不起作用

问题描述

我有一个带有视图控制器成员的选项卡栏视图控制器,它嵌入在导航视图控制器中。在这个视图控制器中,我有一个带有项目列表的表格视图。当您单击一个项目时,您将被定向到另一个视图控制器。这是所选行的代码:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    print([indexPath.row])

    let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)

    let sleepViewController = storyBoard.instantiateViewController(withIdentifier: "SleepItemEnter") as! SleepEnterTimesViewController

    sleepViewController.daySelected =  sleepList[indexPath.row].dayOfWeek
    sleepViewController.daySelectedInt =  indexPath.row

    self.navigationController?.pushViewController(sleepViewController, animated: true)
}

现在它在我测试的所有 iPhone 上都运行良好。但是现在我在 iPad Pro 上测试了一下,还是不行。“self.navigationController?.pushViewController”行不起作用。新的视图控制器根本没有显示。

为什么会这样,只在 iPad 上?

标签: iosswiftuitableviewuiviewcontroller

解决方案


推荐阅读