这是我的功能:
func myFunction(sender:UILongPressGestureRecognizer, index: Int){
print(sender.view?.tag)
}
在 cellForItemsInSection 中,这是我所做的:
let gesture UILongPressGestureRecognizer()
gesture.addTarget(self, action: #selector(self.myFunction(_:))) //here I want to call the second parameter with the indexPath.row but how?
gesture.view?.tag = indexPath.row
最佳答案
您不能在 UIGestureRecognizer
操作中传递两个参数。
来自documentation :
The action methods invoked must conform to one of the following signatures:
- (void)handleGesture;
- (void)handleGesture:(UIGestureRecognizer *)gestureRecognizer;
关于swift - 从 cellForItemsInSection 中的 #selector 调用带有两个参数的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39636046/