在iOS 8+中,我注意到如果你有一个目前firstResponder在视图控制器中显示的文本字段,当视图控制器被解除时,键盘会在被解雇之前挂起约1秒钟.
iOS 8.0和8.1而不是 7.1 都会出现这种情况.
任何想法为什么会这样?
我正在编写一种方法来检查当前用户设置是否包含某些通知类型.
检查当前设置是否包含UIUserNotificationsType.None时,在给出和拒绝权限时,它都返回true.谁会知道为什么会这样?
func registerForAllNotificationTypes()
{
registerNotificationsForTypes([.Badge, .Alert, .Sound])
}
func registerNotificationsForTypes(types:UIUserNotificationType)
{
let settings = UIUserNotificationSettings.init(forTypes:types, categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(settings)
}
func isRegisteredForAnyNotifications() -> Bool
{
let currentSettings = UIApplication.sharedApplication().currentUserNotificationSettings()
print(currentSettings)
print((currentSettings?.types.contains(.Alert))!)
print((currentSettings?.types.contains(.Badge))!)
print((currentSettings?.types.contains(.Sound))!)
print((currentSettings?.types.contains(.None))!)
return (currentSettings?.types.contains(.Alert))! //Just testing .Alert for now
}
Run Code Online (Sandbox Code Playgroud)
获得许可时:
Optional(<UIUserNotificationSettings: 0x7fabdb719360; types: (UIUserNotificationTypeAlert UIUserNotificationTypeBadge UIUserNotificationTypeSound);>)
true
true
true
true
许可关闭时:
Optional(<UIUserNotificationSettings: 0x7f96d9f52140; types: (none);>)
false
false
false
true