作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
好吧,我完全改变了以前的代码,这就是我需要的,但是最后推送到导航 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/
我是一名优秀的程序员,十分优秀!