The app that I am working on has a UITableViewController embedded in a UINavigationController. Tapping on cells in the UITableViewController presents other UIViewControllers. I am trying to implement 3D touch in an iOS app so that the user can directly access one of the UIViewControllers from the home screen. Everything works fine except that when I tap on the link on the home screen, I get a black screen (except for the navigation bar). Here is the relevant code from the 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
}
I'm reasonably sure that I'm getting to the correct UIViewController
each time, but the screen is black. I can navigate back to the UITableViewController
, where I can then segue back to the UIViewController
and it works just fine. So it is clearly something in the presentation of the window that is messed up.
Thanks in advance for any and all advice.
UIViewController
you open, can you debug and check what all methods get called by either using break points or addingUIAlertView
. DoesviewDidLoad
get called? DoesviewDidAppear
? What is happening inside the openedUIViewController
? – RikhviewDidLoad
in all 6 of them just in case they were mis-targeted. Also, when the UIViewControllers are accessed via segue from the UITableViewController, all the lifecycle methods are called. – Glenn