Pass a NSDictionary as parameter to UITapGestureRecognizer

后端 未结 3 1597
悲&欢浪女
悲&欢浪女 2020-12-11 08:31

I want to pass a NSArray as a parameter to UITapGestureRecognizer and access it in downloadOptionPressed method. How can I do this ?

The

3条回答
  •  我在风中等你
    2020-12-11 08:50

    Sometimes with passing an index is enough, in that case the tag property view is your ally. In the following exampled I pretended to add a long press into a tableview cell. And once the event was triggered, I just wanted to know which cell was long pressed:

        let longPress = UILongPressGestureRecognizer(target: self, action: "longPress:")
        cell.tag = indexPath.row
        cell.addGestureRecognizer(longPress)
    

    ...

    func longPress(guesture: UILongPressGestureRecognizer) {
        print("\(guesture.view!.tag)")} }
    

提交回复
热议问题