How to get the indexpath.row when an element is activated?

前端 未结 19 2317
梦如初夏
梦如初夏 2020-11-21 23:30

I have a tableview with buttons and I want to use the indexpath.row when one of them is tapped. This is what I currently have, but it always is 0

var point =         


        
19条回答
  •  我寻月下人不归
    2020-11-22 00:04

    For Swift2.1

    I found a way to do it, hopefully, it'll help.

    let point = tableView.convertPoint(CGPoint.zero, fromView: sender)
    
        guard let indexPath = tableView.indexPathForRowAtPoint(point) else {
            fatalError("can't find point in tableView")
        }
    

提交回复
热议问题