私が作業しているアプリケーションには、UINavigationControllerに埋め込まれたUITableViewControllerがあります。 UITableViewControllerのセルをタップすると、他のUIViewControllerが表示されます。私は、ユーザーがホーム画面からUIViewControllerの1つに直接アクセスできるように、iOSアプリケーションに3Dタッチを実装しようとしています。ホーム画面のリンクをタップすると、黒い画面が表示されます(ナビゲーションバーを除く)。ここでAppDelegate
から関連するコードです:3Dタッチクイックアクションで黒い画面が表示されます。 UiNavigationController-> UITableViewController-> UIViewController
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'の内部で何が起こっていますか? – Rikh
AppDelegateから提示されるUIViewControllerで呼び出されるライフサイクルメソッドはありません。私は、彼らが誤ってターゲットとされていた場合に備えて、それらの6つすべてで 'viewDidLoad'に休憩を入れました。また、UITableViewControllerからsegue経由でUIViewControllerにアクセスすると、すべてのライフサイクルメソッドが呼び出されます。 – Glenn