【发布时间】:2015-11-03 14:32:08
【问题描述】:
我有一个超类,它有一个应该在子类上呈现视图控制器的函数。我有两个来自超类的子类,它应该出现在当前可见的任何一个上。目前它只从其中一个呈现,并且仅在可见时呈现。
骨架代码:
class Superclass : UIViewController {
func somethingHappened() {
if let navigation = self.navigationController {
navigation.presentViewController(controllerToPresent, animated: true, completion: { () -> Void in
// Stuff
})
} else {
self.presentViewController(controllerToPresent, animated: true, completion: { () -> Void in
// Stuff
})
}
}
}
我的一个视图控制器SubclassA 是导航控制器的根视图控制器,它通过函数的else。另一个SubclassB 被推到SubclassA 上,并且通过第一部分。 SubclassB 是唯一成功呈现视图控制器的视图控制器。
controllerToPresent 也不为零。
Warning: Attempt to present <UINavigationController> on <SubclassB> whose view is not in the window hierarchy!
【问题讨论】:
-
好的,你的问题是什么?
-
为什么
SubclassA上的视图控制器不显示,我该如何解决?
标签: ios swift inheritance