Detecting which UIButton was pressed in a UITableView

前端 未结 26 2910
小蘑菇
小蘑菇 2020-11-22 00:40

I have a UITableView with 5 UITableViewCells. Each cell contains a UIButton which is set up as follows:

- (UITableView         


        
26条回答
  •  离开以前
    2020-11-22 00:59

    To do (@Vladimir)'s answer is Swift:

    var buttonPosition = sender.convertPoint(CGPointZero, toView: self.tableView)
    var indexPath = self.tableView.indexPathForRowAtPoint(buttonPosition)!
    

    Although checking for indexPath != nil gives me the finger..."NSIndexPath is not a subtype of NSString"

提交回复
热议问题