【问题标题】:3D Touch Quick Action launches black screen. UiNavigationController->UITableViewController-> UIViewController3D Touch Quick Action 启动黑屏。 UiNavigationController->UITableViewController-> UIViewController
【发布时间】:2017-02-15 10:46:24
【问题描述】:

我正在开发的应用程序有一个嵌入在 UINavigationController 中的 UITableViewController。点击 UITableViewController 中的单元格会显示其他 UIViewController。我正在尝试在 iOS 应用程序中实现 3D 触摸,以便用户可以直接从主屏幕访问 UIViewController 之一。一切正常,除了当我点击主屏幕上的链接时,我得到一个黑屏(导航栏除外)。以下是来自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,它工作得很好。所以很明显,在窗口的呈现中有些东西搞砸了。

提前感谢您的任何建议。

【问题讨论】:

  • 可能无法在屏幕上显示数据。使用断点检查您的数据源。
  • 在您打开的UIViewController 中,您是否可以通过使用断点或添加UIAlertView 来调试并检查所有方法被调用的内容。 viewDidLoad 会被调用吗? viewDidAppear 吗?打开的UIViewController里面发生了什么?
  • 据我所知,在 AppDelegate 提供的 UIViewController 中没有调用任何生命周期方法。我在所有 6 个中都添加了viewDidLoad,以防它们被错误定位。此外,当通过从 UITableViewController 中的 segue 访问 UIViewControllers 时,会调用所有生命周期方法。

标签: ios iphone swift uiviewcontroller uinavigationcontroller


【解决方案1】:

问题出在我的info.plist 文件中。我错误地认为$(PRODUCT_BUNDLE_IDENTIFIER) 作为UIApplicationShortcutItemType 的前缀将是我的包标识符。不是,所以用我的显式包标识符替换 $(PRODUCT_BUNDLE_IDENTIFIER) 就可以了。

感谢cmets,最终让我找到了答案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-03
    • 1970-01-01
    • 1970-01-01
    • 2014-09-19
    相关资源
    最近更新 更多