我想传递发件人redBox
到函数leftSwipeFunc
。我不知道如何传递一个不是的参数UISwipeGestureREcognizer
。如果您知道答案,请帮助我。
let swipeLeft = UISwipeGestureRecognizer(target: self, action: Selector("leftSwipeFunc:"))
swipeLeft.direction = UISwipeGestureRecognizerDirection.Left
redBox.addGestureRecognizer(swipeLeft)
func leftSwipeFunc(gesture:UISwipeGestureRecognizer){ }
手势识别器有一个属性称为view
那就是UIView
他们所依附的。所以,你可以在里面使用它leftSwipeFunc
获取视图:
func leftSwipeFunc(gesture: UISwipeGestureRecognizer) {
let swipedView = gesture.view
// Assuming redBox is a property of your view controller
if swipedView == redBox {
println("the redBox was swiped")
} else {
println("some other view was swiped")
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)