1

I placed a view inside a TableView Cell and have divided that view into 7 parts. Also, each view is assigned with a tag. Now, whenever I select a view, I want to find out the tag for identification and all I am getting is indexPath of the cell and details of all the views in it. How can I find out the exact location or tag of the selected view? Don't want to use gesture. Can anyone help me out with this. Thanks in advance.

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

var cell = tableView?.cellForRow(at: indexPath)
     print(cell?.contentView.subviews)


}
Priya
  • 351
  • 1
  • 14

1 Answers1

0

What tag is that, you could get your cell properties normally after you got the cell.

if let cell = tableView?.cellForRow(at: indexPath) as? YourCellClass {
    tag = cell.tag
}
print(cell?.contentView.subviews)
Đào Minh Hạt
  • 2,742
  • 16
  • 20
  • Thanks for the answer but, I don't want to find out the cell properties instead, I want to know which view is selected inside cell. I want to find out the particular tag of that view out of many other views inside cell. – Priya Mar 06 '17 at 07:51
  • http://stackoverflow.com/questions/20655060/get-button-click-inside-ui-table-view-cell Maybe this is your need, just use buttons for you views. – Đào Minh Hạt Mar 06 '17 at 08:00
  • Can't use button. Actually, I have added labels and image in views. – Priya Mar 06 '17 at 08:17