В моей UITableView
Я много клеток, созданных, как это:Target автоматически вызывается в cellForRowAtIndexPath
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell")! as UITableViewCell
let btn = cell.viewWithTag(1001) as! UIButton
btn.tag = indexPath.row
btn.addTarget(cell, action: Selector(myFunc(btn)), forControlEvents: .TouchUpInside)
...
}
Я не могу понять, почему MyFunc() вызывается автоматически, когда UITableView заполняется. (Не касаясь каких-либо кнопок)
Какую версию Swift вы используете? –
Я использую Swift 2.2 –
Попробуйте переместить свой метод 'btn action' на didSelectRowAtIndexPath? – Joe