4
我搞砸了UILocalNotification
和通知操作 - 除了當我在我的類別中提供兩個Minimal
操作時,所有按我期望的方式工作,當通過通知中心的滑動顯示操作時,最右側行動總是藍色的。UILocalNotification最小操作 - 一個藍色,一個清除?
由於在我的應用程序中的操作是平等的,我寧願他們都是清晰的灰色,而不是一個藍色,一個清晰。我知道我可以用destructive
將它們都變成紅色,但這也是錯誤的,如果我明確地將destructive
設置爲false
,我仍然會得到一個藍色,一個清晰。
這裏的圖像顯示什麼,我說什麼:
這裏是我用來做它的代碼:
let note = UILocalNotification()
note.fireDate = NSDate(timeIntervalSinceNow: 5)
note.timeZone = NSTimeZone.defaultTimeZone()
note.alertBody = "Actions: A and B"
note.alertTitle = "Notification!"
let action1 = UIMutableUserNotificationAction()
action1.identifier = 「ACTION_A"
action1.title = "A"
action1.activationMode = .Background
let action2 = UIMutableUserNotificationAction()
action2.identifier = 「ACTION_B"
action2.title = "B"
action2.activationMode = .Background
let category = UIMutableUserNotificationCategory()
category.identifier = "ANSWERS_CATEGORY"
category.setActions([action1, action2], forContext: .Default)
note.category = 「ACTIONS_CATEGORY"
let categories = Set(arrayLiteral: category)
let settingsRequest = UIUserNotificationSettings(forTypes: [.Alert, .Sound, .Badge], categories: categories)
UIApplication.sharedApplication().registerUserNotificationSettings(settingsRequest)
UIApplication.sharedApplication().scheduleLocalNotification(note)
讓我們希望我們比寓意多一點繼續 - 但感謝您挖掘它。 – Luke
看起來這是正確的,我唯一的選擇是與它一起生活,或使它們都變成紅色;) – Luke