从UNUserNotificationCenterDelegate呈现ViewController

时间:2018-05-15 16:21:34

标签: swift uiviewcontroller uikit

在我的UNUserNotificationCenterDelegate方法中,我想将用户跳转到特定的视图控制器。我可以从故事板轻松获取VC本身:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "beach")

我现在还不完全确定如何实际呈现它,因为我没有方便的对象调用presentViewController。

1 个答案:

答案 0 :(得分:0)

如果你的root是navigationVC

if let nav = self.window?.rootViewController as? UINavigationController {
    nav.pushViewController(vc, animated: true)
}
相关问题