Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在Swift中,是否有人知道哪个物体被刷过?_Ios_Swift - Fatal编程技术网

Ios 在Swift中,是否有人知道哪个物体被刷过?

Ios 在Swift中,是否有人知道哪个物体被刷过?,ios,swift,Ios,Swift,我想将发送者redBox传递给函数leftSwipeFunc。我不知道如何传递一个不是uisweegestureerecognizer的参数。如果你知道答案,请帮助我 let swipeLeft = UISwipeGestureRecognizer(target: self, action: Selector("leftSwipeFunc:")) swipeLeft.direction = UISwipeGestureRecognizerDirection.Left redBox.addGes

我想将发送者
redBox
传递给函数
leftSwipeFunc
。我不知道如何传递一个不是
uisweegestureerecognizer
的参数。如果你知道答案,请帮助我

let swipeLeft = UISwipeGestureRecognizer(target: self, action: Selector("leftSwipeFunc:")) 
swipeLeft.direction = UISwipeGestureRecognizerDirection.Left
redBox.addGestureRecognizer(swipeLeft) 

func leftSwipeFunc(gesture:UISwipeGestureRecognizer){ }

您可以使用
locationInView
在视图中找到刷卡的位置

在您的
leftSwipeFunc
中,找到触摸屏的
CGPoint
,并检查它是否在所需视图中

let location = gesture.locationInView(self.view)

if CGRectContainsPoint(redBox, location) {
    // redBox was swiped, do something
}

手势识别器有一个名为
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")
    }
}