imzyf / ios-swift-learning-notes

📝 iOS Swift Learning Notes - see Issues
MIT License
0 stars 0 forks source link

uibutton 事件绑定 复用问题 #73

Closed imzyf closed 6 years ago

imzyf commented 6 years ago

cell 中绑定 uibutton target 时,可能出现多次绑定的问题。应该在绑定前先移除原来的

cell.playButton.removeTarget(nil, action: nil, for: .allEvents)

cell.playButton.addTarget(self, action: #selector(playWordTTS(sender:)), for: .touchUpInside)
imzyf commented 6 years ago

使用代理进行事件绑定