I have a tableview controller that displays a row of cells. Each cell has 3 buttons. I have numbered the tags for each cell to be 1,2,3. The problem is I don't know how to find on which cell a button is being pressed. I'm currently only getting the sender's tag when one of the buttons has been pressed. Is there a way to get the cell row number as well when a button is pressed?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
- How can I add media attachments to my push notific
Another simple way:
Get the point of touch in tableView
Then get index path of cell at point
The index path contains row index
The code is:
Edit: This answer is outdated. Please use this method instead
Try this:
Edit: If you are using contentView, use this for buttonCell instead:
I assume you add buttons to cell in
cellForRowAtIndexPath
, then what I would do is to create a custom class subclassUIButton
, add a tag calledrowNumber
, and append that data while you adding button to cell.In swift: