i would like to build a custom table view cell and put in him a button and when the user click the button to go to a method-and the method will know which cell the button was pressed.
thx
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can give the button a tag. If you set this tag to be the number of the cells indexPath.row you can always determine from which cell the button was clicked by retrieving the tag Value.
Button tag has to be an integer btw, but sow is indexPath.row.
Here I create a custom cell displaying details of a ‘Huis’. When setting the object for the cell I also pass the indexPath.row of the cell that I am filling.
Then in the custom cell, upon setting the object, I also set the tag value for my button like this:
The button might have already been created / initialized, in that case you only set the tag. Now in the function handling your ControlEvent you can access this tag like so: