当点击推送通知并转到Swift 3.0中的特定ViewController时,Tab栏没有显示?

时间:2017-09-29 09:23:23

标签: swift3 apple-push-notifications

当我点击通知时,我正在接收Push Notifications当我点击我点击SlideMenu didSelectRow时,我想要转到特定的ViewController。我尝试了很多SO链接但是在代码下面我可以转到特定的ViewController,但问题是tabBar它没有显示。

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {

        let mainstoryboard = UIStoryboard(name: "Main", bundle: nil)
    let ringingVC = mainstoryboard.instantiateViewController(withIdentifier: "RaffleResultViewController") as? RaffleResultViewController

    window?.rootViewController = ringingVC
}

1 个答案:

答案 0 :(得分:0)

let mainstoryboard = UIStoryboard(name: "Main", bundle: nil)
let ringingVC = mainstoryboard.instantiateViewController(withIdentifier: "RaffleResultViewController") as? RaffleResultViewController

let selectedVC = window.rootViewController

if let nav = selectedVC as? UINavigationController{
    nav.pushViewController(ringingVC, animated: true)
}else{
    selectedVC.present(ringingVC, animated: true, completion: nil)
}

//使用此