我是iOS開發新手!我試圖用UILocalNotification
創建一個應用程序。以下是我所做的:applicationIconBadgeNumber不更新或增加
func createLocalNotification(structure:Structure) {
let localNotification = UILocalNotification()
localNotification.category = "CATEGORY"
localNotification.alertBody = "\(structure.messageBody)"
localNotification.alertAction = "see"
localNotification.soundName = UILocalNotificationDefaultSoundName
localNotification.userInfo = ["uuid":structure.UUID]
localNotification.fireDate = structure.date
localNotification.applicationIconBadgeNumber = UIApplication.sharedApplication().applicationIconBadgeNumber + 1
print(localNotification)
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
}
它運作良好!我的問題是applicationBadgeNumber
。這property
似乎有效。但在應用程序處於非活動狀態時不會增加。然後啓動一個應用程序Xcode給我這樣一個錯誤:
快照未呈現的視圖會導致一個空的快照。確保您的視圖在屏幕更新後的快照或快照之前已呈現至少一次。
什麼意思?什麼是錯的?謝謝你的幫助!