Hello,
How can i get section cell text on custom cell button click.
is this possible?
Thank you,
Hello,
How can i get section cell text on custom cell button click.
is this possible?
Thank you,
When you are drawing the cell set the tag on the button as an index into the array of data that you are displaying
[acceptAnswersButton setTag:indexPath.row]
Then when the button is clicked you can get the tag from the action that is called as the button will be passed as a parameter.
If you add the tag to the button for each row. Then in the associated action you have the index into the array that you got the text from to retrieve it again.
arrayText = {"one", "two", "three"}
This means that the cellForRowAtIndexPath will set the tag for each button as
row1ButtonTag=0
row2ButtonTag=1
row3ButtonTag=2
and when the action is called you will have access to the button that called the action and therefore access to the index into the array
(IBAction)myAction:(id)sender {
NSString *theTextIWasLookingFor = [arrayText objectAtIndex:((UIButton*)sender).tag];
}