我正在使用的应用程序具有嵌入在uinavigationController中的UITATION VIEWCONTROLLER。在UitaiteViewController中敲击单元格会呈现其他UiviewControllers。我正在尝试在iOS应用程序中实现3D触摸,以便用户可以直接从主屏幕访问一个UiviewControllers。一切正常,除了我点击主屏幕上的链接时,我会得到黑屏(导航栏除外)。这是AppDelegate
的相关代码:
func handleShortCutItem(shortcutItem: UIApplicationShortcutItem) -> Bool {
var handled = false
guard ShortcutIdentifier(fullType: shortcutItem.type) != nil else { return false }
guard let shortCutType = shortcutItem.type as String? else { return false }
let storyboard = UIStoryboard(name: "Main", bundle: nil)
var vc = UIViewController()
switch (shortCutType) {
case ShortcutIdentifier.Tables.type:
vc = storyboard.instantiateViewController(withIdentifier: "TableVC") as! StatTableViewController
handled = true
break
case ShortcutIdentifier.ChiSquare.type:
vc = storyboard.instantiateViewController(withIdentifier: "Chisquare") as! CSViewController
handled = true
break
case ShortcutIdentifier.PowerContinuous.type:
vc = storyboard.instantiateViewController(withIdentifier: "PowerCont") as! PowerContViewController
handled = true
break
case ShortcutIdentifier.PowerDichotomous.type:
vc = storyboard.instantiateViewController(withIdentifier: "PowerDichot") as! PowerDichotViewController
handled = true
break
default:
break
}
let navVC = self.window?.rootViewController as! UINavigationController
navVC.pushViewController(vc, animated: true)
// navVC.show(vc, sender: self) // Same result
return handled
}
我可以合理地确定我每次都可以使用正确的UIViewController
,但是屏幕是黑色的。我可以导航回UITableViewController
,然后可以将其返回到UIViewController
,而且效果很好。因此,显然在窗口的介绍中被弄乱了。
事先感谢所有建议。
问题在我的info.plist
文件中。我错误地认为$(PRODUCT_BUNDLE_IDENTIFIER)
是UIApplicationShortcutItemType
的前缀,这是我的捆绑符号。不是,所以用我的显式捆绑包标识符替换$(PRODUCT_BUNDLE_IDENTIFIER)
的技巧。
感谢您的评论,这最终导致了我找到答案。