I am having a problem with Swift 3 action selectors - or, I can say, with gesture recognizers.
Suppose I am in a table view where I am having dynamic data through a table cell. I have one button or gesture recogniser in the table view and I want to send data from that button or gesture to a different function.
答案 0 :(得分:1)
Please try the below function, Hope it will work for you!!
func whereYouWant(){
let button = UIButton()
button.accessibilityElements = [data1,data2]//Here you can pass any thing in this array.
button.addTarget(self, action: #selector(testFunction), for: .touchUpInside)
}
//Here you can call this function through selector....
func testFunction(myButton:UIButton){
let firstData = myButton.accessibilityElements?[0] as? //Here you can do type cast According to you
let secondData = myButton.accessibilityElements?[1] as? //Here you can do type Cast According to you.
}