【发布时间】:2016-02-15 02:29:22
【问题描述】:
我的 TabBarVC 是我的应用程序的核心。我有 3 个视图控制器。每个视图控制器都“嵌入”在导航控制器中。
TabBarVC -> UINavigationController -> HomeVC
-> UINavigationController -> TimelineVC
-> UINavigationController -> ConversationVC
我希望我的TabBarVC 能够随时将InstantMessageViewController 推送到它的堆栈上。我知道 TabBarVC 没有“堆栈”或 NavigationController - 只有它的子级才有导航控制器。
当TabBarVC 收到NSNotification 时,我想将InstantMessageViewController 推入其堆栈。
TabBarVC 里面可能有这样的东西?
let mvc = self?.storyboard?.instantiateViewControllerWithIdentifier("MessagesViewController") as! InstantMessagesViewController
mvc.user = self?.notificationUser
self?.navigationController?.pushViewController(mvc, animated: true) //it doens't work because self.navigationController is nil.
当用户按下返回按钮时,它会返回到 TabBarVC。
我希望能够随时将多个InstantMessagesViewController 推入堆栈并以编程方式重新排序。
我不知道什么是最好的方法。我要创建一个 UIWINdow 吗?我是否以编程方式创建 UINavigationController?
【问题讨论】:
标签: ios objective-c swift