3D Touch Quick Action启动黑屏。 UiNavigationController-> UITableViewController->的UIViewController

时间:2017-02-15 10:46:25

标签: ios iphone swift uiviewcontroller uinavigationcontroller

我正在处理的应用程序在UINavigationController中嵌入了一个UITableViewController。点击UITableViewController中的单元格会显示其他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,它可以正常工作。所以在窗口的呈现中显然是搞砸了。

提前感谢任何建议。

1 个答案:

答案 0 :(得分:0)

问题原来是我的public boolean isPolygonsIntersecting(Polygon2D.Double a, Polygon2D.Double b) { for (int x = 0; x < 2; x++) { Polygon2D.Double polygon = x == 0 ? a : b; for (int i1 = 0; i1 < polygon.getPoints().length; i1++) { int i2 = (i1 + 1) % polygon.getPoints().length; CustomPoint p1 = polygon.getPoints()[i1]; CustomPoint p2 = polygon.getPoints()[i2]; CustomPoint normal = new CustomPoint(p2.y - p1.y, p1.x - p2.x); double minA = Double.POSITIVE_INFINITY; double maxA = Double.NEGATIVE_INFINITY; for (CustomPoint p : a.getPoints()) { double projected = normal.x * p.x + normal.y * p.y; if (projected < minA) minA = projected; if (projected > maxA) maxA = projected; } double minB = Double.POSITIVE_INFINITY; double maxB = Double.NEGATIVE_INFINITY; for (CustomPoint p : b.getPoints()) { double projected = normal.x * p.x + normal.y * p.y; if (projected < minB) minB = projected; if (projected > maxB) maxB = projected; } if (maxA < minB || maxB < minA) return false; } } return true; } 文件。我错误地认为info.plist作为$(PRODUCT_BUNDLE_IDENTIFIER)的前缀将是我的包标识符。它不是,所以用我的显式包标识符替换UIApplicationShortcutItemType就可以了。

感谢您的评论,最终导致我找到答案。