【iOS】swift-Binary operator '|' cannot be applied to two UIViewAutoresizing operands

let view = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 568))
addSubview(view)

view.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight

会报以下错误:

Binary operator '|' cannot be applied to two UIViewAutoresizing operands

更改为:

view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
即可解决
但是在极光推送中遇到同样问题后,这样并不行
原OC代码:

      [JPUSHService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |

                                                        UIUserNotificationTypeSound |

                                                        UIUserNotificationTypeAlert)

                                            categories:nil];

转为swift
        JPUSHService.registerForRemoteNotificationTypes(UIUserNotificationType.Badge.rawValue | UIUserNotificationType.Sound.rawValue | UIUserNotificationType.Alert.rawValue, categories: nil)
就是swift 和 OC 在枚举上的区别导致的




posted @ 2016-01-28 14:27  云端止水  阅读(496)  评论(0编辑  收藏  举报