【发布时间】:2020-05-18 01:14:57
【问题描述】:
我是 swift 新手,但我已经实施了 FCM,但我遇到了问题。当我单击通知时,它会使用以下代码加载NotificationsViewController。
let sb = UIStoryboard(name: "Main", bundle: nil)
let otherVC = sb.instantiateViewController(withIdentifier: "NotificationsViewController") as! NotificationsViewController
self.window?.rootViewController = otherVC;
一旦NotificationsViewController 被加载,我在后退按钮上使用以下代码将根视图重新分配回普通 ViewController。
let mainStoryBoard = UIStoryboard(name: "Main", bundle: nil)
let redViewController = mainStoryBoard.instantiateViewController(withIdentifier: "splashScreen") as! ViewController
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.window?.rootViewController = redViewController
一旦我在splashScreen 上,它应该会显示一个快速图像,然后使用此代码转到主仪表板。
let vw = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "DashboardViewController") as! DashboardViewController
self.navigationController?.pushViewController(vw, animated: true)
我遇到的问题是当应用程序从NotificationsViewController 加载它时splashScreen 代码不起作用,它只是挂在那个VC 上,但是如果我加载splashScreen 而不重新分配根视图它可以工作。
那么我还有其他方法吗?我只想在用户点击通知时将他们带到NotificationsViewController,然后在他们点击后退按钮时返回应用程序的主要部分。
【问题讨论】:
标签: ios swift viewcontroller