UIRemoteNotificationTypeSound

UIRemoteNotificationTypeSound

当我使用[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];注册远程推送通知时,发生错误,说cannot initialize a parameter of type 'UIRemoteNotificationType' with an rvalue of type 'int',有人知道为什么吗?谢谢你。
我项目的环境:Xcode 4.2 + iOS 5。

最佳答案

您应该将其显式转换为UIRemoteNotificationType

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationType)(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

10-04 22:04