我試圖設置一個值到我的tabbar中的標籤欄項目,這是在故事板上創建的,每次通過我的應用程序委託推送遠程通知時。我不斷收到此錯誤:更新Swift Coulld中的TabBar徽章不是類型UINavigationController的轉換值
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()
}
是否可以看到故事板的佈局? – ndmeiri