[英]How to open ViewController From AppDelegate With NavigationBar?
當我從 OneSignal 收到通知時,我想從 AppDelegate 打開 ViewController,它正在工作,但問題是當 ViewController 打開時沒有工具欄,我如何用工具欄打開它? 我正在使用嵌入導航控制器。
這是 AppDelegate 中打開 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()
(1) 當你說“工具欄”時,你指的是“導航欄”嗎? (提示:它們是完全不同的東西。)
(2)你的代碼中沒有導航控制器,自然也就不會出現導航欄了。 這個“嵌入導航控制器”在哪里? 如果它在情節提要中,那么您在代碼的第二行中實例化了錯誤的視圖控制器; 您需要實例化導航控制器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.