【发布时间】:2015-09-14 15:32:52
【问题描述】:
我尝试为在情节提要上创建的标签栏中的标签栏项目设置一个值,每次通过我的应用程序委托推送远程通知时。我不断收到此错误:
Could not cast value of type 'UINavigationController' (0x19632c0b0) to 'UITabBarController' (0x19632d230).
代码:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
var tabBarController = self.window!.rootViewController as! UITabBarController
...
var tabArray = tabBarController.tabBar.items as NSArray!
var tabItem = tabArray.objectAtIndex(3) as! UITabBarItem
tabItem.badgeValue = "34"
...
}
println("notification")
//scheduleNotification()
}
【问题讨论】:
-
可以看到你的故事板的布局吗?
标签: swift uinavigationcontroller push-notification uitabbarcontroller