我正在尝试为我的iOS应用程序实现3D快速操作。 我已经设法添加快速操作,并希望在故事板中打开一个viewcontroller。使用UITabbarController和UINavigationController从故事板调用视图
我的根控制器是一个UITabbarController。在这里面我有一个UINavigationController。
我已经按照这个tutorial
然后我想打开的的appdelegate搜索视图中,我试图做这样的教程。但我只看到一个黑屏。
func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {
if shortcutItem.type == "com.traning.addStuff" {
let sb = UIStoryboard(name: "Main", bundle: nil)
let searchVC = sb.instantiateViewControllerWithIdentifier("Search") as! SearchView
let root = UIApplication.sharedApplication().keyWindow?.rootViewController
root?.presentViewController(searchVC, animated: false, completion: {() -> Void in
completionHandler(true)
})
}
}
我的ViewController是我的UINavigationController
[UITab]第三视图 - 控制 - > [UINav] - > [UINav] - > [UINav]
我试图初始化根作为UITabbarController查看,但我如何访问或调用我的视图为UINavigationController?
有什么建议吗?
谢谢!
编辑:
我已经添加的图像来说明我的故事板(这只是一个例子) 我有一个的UITabBarController - >的UINavigationController - >的firstView - > SecondView
随着我想要调用SecondView的3D快速操作。
在呈现之前,尝试根是否尝试根?.definesPresentationContext = true。希望有帮助:) –
@LucianoAlmeida嘿谢谢你,但它仍然无法正常工作。我收到这个日志输出。警告:试图在上呈现,其视图不在窗口层次结构中! –
we7ee
既然你有这个日志,你可以试试这种方式:let root = UIApplication.sharedApplication().keyWindow?.rootViewController。改为visibleViewController。希望工程:) –