Home > database >  How to open ViewController From AppDelegate With NavigationBar?
How to open ViewController From AppDelegate With NavigationBar?

Time:12-18

i want to open ViewController From AppDelegate when i get notification from OneSignal, and its working but the problem is when ViewController opened there is not toolbar , how can i open it with toolbar ? i am using embed in Navigation Controller.

this is the code in AppDelegate to open ViewController

let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
                let instantiateRedViewController : ViewController = mainStoryboard.instantiateViewController(withIdentifier: "ViewControllerID") as! ViewController
                instantiateRedViewController.receivedURL = additionalData["openURL"] as! String?
                self.window = UIWindow(frame: UIScreen.main.bounds)
                self.window?.rootViewController = instantiateRedViewController
                self.window?.makeKeyAndVisible()

CodePudding user response:

(1) When you say "toolbar" do you mean "navigation bar"? (Hint: They are totally different things.)

(2) There is no navigation controller in your code, so naturally no navigation bar appears. Where is this "embed in Navigation Controller"? If it's in the storyboard, then you are instantiating the wrong view controller in the 2nd line of your code; you need to instantiate the navigation controller.

  • Related