gpt4 book ai didi

swift - 推送到导航 Controller 不起作用

转载 作者:行者123 更新时间:2023-11-30 13:27:59 25 4
gpt4 key购买 nike

好吧,我完全改变了以前的代码,这就是我需要的,但是最后推送到导航 Controller 不起作用

        if application.applicationState == UIApplicationState.Background || application.applicationState == UIApplicationState.Inactive {
if let user = userInfo["user"] as? String{
User.loadUserById(user, completion: {result in
let rootViewController = UIApplication.sharedApplication().keyWindow?.rootViewController as! SWRevealViewController
let StoryB = UIStoryboard(name: "Main", bundle: nil)
let Logged : UITabBarController = StoryB.instantiateViewControllerWithIdentifier("TabBarController") as! UITabBarController
rootViewController.setFrontViewPosition(FrontViewPosition.Left, animated: true)
let profileViewController : UserProfileVC = StoryB.instantiateViewControllerWithIdentifier("UserProfileVC") as! UserProfileVC
profileViewController.user = result
rootViewController.pushFrontViewController(Logged, animated: true)
let wc = rootViewController.frontViewController as! UITabBarController
if let wcc = wc.selectedViewController as? UINavigationController{
wcc.pushViewController(profileViewController, animated: true)
}

})

}

}

最佳答案

我将新的 tabbarcontroller 推送到 root 是错误的,此代码有效

        if application.applicationState == UIApplicationState.Background || application.applicationState == UIApplicationState.Inactive {
if let type = userInfo["type"] as? String{
if type == "wink" || type == "met" {
if let user = userInfo["user"] as? String{
User.loadUserById(user, completion: {result in
if let rootViewController = UIApplication.sharedApplication().keyWindow?.rootViewController as? SWRevealViewController{

let StoryB = UIStoryboard(name: "Main", bundle: nil)
rootViewController.setFrontViewPosition(FrontViewPosition.Left, animated: true)
let profileViewController : UserProfileVC = StoryB.instantiateViewControllerWithIdentifier("UserProfileVC") as! UserProfileVC
profileViewController.user = result
if let tabBar = rootViewController.frontViewController as? UITabBarController{
if let navigationController = tabBar.selectedViewController as? UINavigationController{
navigationController.pushViewController(profileViewController, animated: true)
}
}

}

})

}
}
}

}

关于swift - 推送到导航 Controller 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36909608/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com