我目前正在使用一个用Objective-C编写的CocoaPod。在示例中,他们展示了以下内容:
options.allowedSwipeDirections = MDCSwipeDirectionLeft | MDCSwipeDirectionRight;
我甚至不知道这种变量叫什么,但我已经在Swift中尝试过以下内容:
options.allowedSwipeDirections = MDCSwipeDirection.Left | MDCSwipeDirection.Right
但编译器说:No '|' candidates produce the expected contextual result type 'MDCSwipeDirection'
我应该如何在Swift中解决这个问题?
编辑:
看起来这不是一个OptionSet
,就像一些答案所述,这是声明:
/*!
* Contains the directions on which the swipe will be recognized
* Must be set using a OR operator (like MDCSwipeDirectionUp | MDCSwipeDirectionDown)
*/
@property (nonatomic, assign) MDCSwipeDirection allowedSwipeDirections;
它的使用方式如下:
_allowedSwipeDirections = MDCSwipeDirectionLeft | MDCSwipeDirectionRight;
[.Left, .Right]
这样使用 - Bhavin Bhadani