ios - parentViewController 和presentingViewController 都为零

标签 ios iphone swift navigationcontroller

我有一个带有 5 个选项卡的 tabBarController,第三个选项卡是一个导航 Controller ,其中 TableViewController 作为 Root View Controller 。

当我按下 TableView 上的一行时,它会推送有关所选行的详细信息 View (常规 View Controller )。

问题是第一次设置parentViewController和presentingViewcontroller属性(在详细信息页面中),所有其他连续的两个属性都设置为nil。

The storyboard (auto layout is disabled)

编辑 我创建了一个带有与图中相同的导航 Controller 的单选项卡应用程序,但每次正确设置parentViewController 时,我都没有在 Storyboard 中禁用自动布局。

如果您禁用自动布局,我相信这是一个错误。

最佳答案

您既没有创建 subview Controller ,也没有呈现模式。

(将详细 View Controller 推送到导航 Controller 的堆栈上有点像添加子级,但导航 Controller 早于父/ subview Controller 机制,因此它们不使用它。)

您需要检查的是详细 View Controller 的 navigationController 属性。如果它被推送到导航 Controller 堆栈上,那么它应该是非零。

关于ios - parentViewController 和presentingViewController 都为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32789226/

相关文章:

iphone - 有没有办法在一段时间后自动关闭警报 View ?

iphone - iOS 中的嵌入字体 : why are they not centered correctly on the y axis?

iphone - 将 uiimage 转换为 nsdata 时内存泄漏应用程序崩溃

arrays - 如何快速获取数组中最大元素的数量

ios - 一次性呈现2个navigationController在一个堆栈中

ios - RegEx:如何在 NSPredicate 中使用正则表达式?

ios - 删除导航标题搜索​​栏中的边框

php - 使用 Alamofire 从 PHP 服务器检索 JSON 时出现问题

ios - 从电话簿 iOS Swift 获取电子邮件联系人

ios - 如何从 UICollectionView performBatchUpdates : 中的断言失败中优雅地恢复