Binary operator ‘|’ cannot be applied to two ‘UIViewAutoresizing’ operands

OC的写法:

_tableView.autoresizingMask	= UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight

swift的写法:

_tableView.autoresizingMask	= .flexibleHeight | .flexibleWidth


如果是把OC的代码直接翻译成swift的话,直接按照上面的写法来写的话,会 报错的,报错如下:

Binary operator ‘|’ cannot be applied to two ‘UIViewAutoresizing’ operands

错误原因是:

swift 2.x 和swift 3 对于OptionSetType这个类型进行了优化升级修改。


解决方案是:

_tableView.autoresizingMask = [.flexibleHeight,.flexibleWidth]



你可能感兴趣的:(Swift记录,解决方案,swift)