这是objective-c代码:
options.onPan = ^(MDCPanState *state){
if (state.thresholdRatio == 1.f && state.direction == MDCSwipeDirectionLeft) {
NSLog(@"Let go now to delete the photo!");
}
};
夫特:
var options = MDCSwipeToChooseViewOptions()
options.delegate = self
options.likedText = "Keep"
options.likedColor = UIColor.blueColor()
options.nopeText = "Delete"
options.onPan = { (state: MDCPanState) in
if state.thresholdRatio == 1.0 && state.direction == MDCSwipeDirection.Left {
println("Let go now to delete the photo!");
}
}
这是一个错误:
'(MDCPanState) - > (MDCPanState) - > $ T2'不能转换为' MDCPanState'
非常感谢一些帮助,谢谢。
答案 0 :(得分:1)
我不是百分之百,因为我现在附近没有XCode,但我相信你需要改变这个:
options.onPan = { (state: MDCPanState) in
if state.thresholdRatio == 1.0 && state.direction == MDCSwipeDirection.Left {
println("Let go now to delete the photo!");
}
到此:
options.onPan = { (state: MDCPanState!) -> Void in
if state.thresholdRatio == 1.0 && state.direction == MDCSwipeDirection.Left {
println("Let go now to delete the photo!");
}