UI flow:
AppDelegate
-->
LoginViewController
(not in the storyboard)
-->
navigation controller (in the storyboard)
-->
PFQueryTableViewController
(in the storyboard) named "OrdersVC"
This is the navigation controller with OrdersVC
:
This is my AppDelegate
:
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// ...
// initial VC
let VC = LoginViewController()
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = VC
window!.makeKeyAndVisible()
return true
}
The above works fine. Then, from LoginViewController
, I am then trying to display my storyboard's initial VC which is a navigation controller hosting a PFQueryTableViewController
. Note that LoginViewController
is not in the storyboard.
let destVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("OrdersVC") as! UITableViewController
// will throw "unexpectedly found nil"
let navController = UINavigationController(rootViewController: destVC)
navController.pushViewController(destVC, animated: true)
// will throw "unexpectedly found nil"
self.presentViewController(navController, animated: true, completion: nil)
Problem is that in my PFQueryTableViewController
's viewDidLoad
and viewDidAppear
the following statement is always nil
:
// navitaionController is nil
self.navigationController!.navigationBar.translucent = false
So how can I correctly instantiate PFQueryTableViewController inside its navigation controller?