【发布时间】:2017-05-02 07:04:22
【问题描述】:
我正在尝试在我的应用中添加 3D 触摸快速操作。我在 navigationContoller 中嵌入了两个 viewContoller。当用户按下 3D 动作时,它应该将它们带到添加事件视图控制器。但是我收到了这个错误
无法将“Morning_Star_2.AddEventsViewController”(0x1000a2260)类型的值转换为“UINavigationController”(0x1a79cd360)。 2017-05-02 02:51:36.220324-0400 晨星 2[3731:895126] 无法将“Morning_Star_2.AddEventsViewController”(0x1000a2260)类型的值转换为“UINavigationController”(0x1a79cd360)。
这是我的代码
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
if shortcutItem.type == "com.krp.addEvent" {
let sb = UIStoryboard(name: "Main", bundle: nil)
let addEventVC = sb.instantiateViewController(withIdentifier: "addEventVC") as! UINavigationController
self.window?.rootViewController?.present(addEventVC, animated: true, completion: nil)
}
}
我试过改成! UINavigationController 为!添加事件视图控制器。它可以工作,但它不会像正常打开应用程序时那样在我的添加视图控制器的顶部显示导航栏。
【问题讨论】:
-
你能展示你的故事板图片吗?
-
它就在那里@BhupatBheda。请点击“这是我的 main.storyboard”
标签: ios swift3 uinavigationcontroller 3dtouch