I have a prototype cell which with a button and a label in it. The text of the label changes for each cell. I have set up an @IBAction
for the button and would like to get the text for the label in the cell in which the button in pressed. Does anyone know how to do this?
Asked
Active
Viewed 949 times
0

WhimsicalPyro
- 46
- 8
-
does any one can answer this similar problem http://stackoverflow.com/questions/31049551/accessing-custom-cell-attributes-outside-of-cellforrowatindexpath – Nischal Hada Jun 26 '15 at 06:38
2 Answers
0
- In didSelectRowAtIndexPath method you can get selected cell using cellForRowAtIndexPath using indexPath.row
- when you get selected cell object you can access that label which present inside the cell.
I hope it will help you.

Pravin Tate
- 1,145
- 8
- 18
-
does any one can answer this similar problem http://stackoverflow.com/questions/31049551/accessing-custom-cell-attributes-outside-of-cellforrowatindexpath – Nischal Hada Jun 26 '15 at 06:38
0
- (IBAction)buttonHandler:(id)sender{
UIButton *button = (UIButton *)sender;
UITableViewCell *cell = (UITableViewCell *)button.superview;
println("%@",cell.textLabel.text)
}

Yagnesh Dobariya
- 2,241
- 19
- 29
-
does any one can answer this similar problem http://stackoverflow.com/questions/31049551/accessing-custom-cell-attributes-outside-of-cellforrowatindexpath – Nischal Hada Jun 26 '15 at 06:39