Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get UITableView Label Text string - Custom Cell

I have a UITableView with CustomCell. The custom cells contain a UILabel and a UIImageView.

I saw online that it is possible to get the text from a normal UITableView cell and store it in a string when the user presses the cell.

But how can you do this when you are using a custom cell? Becuase the name of my UILabel is "type_label" and it has been defined in the header file of my CustomCell XIB.

So in Xcode I can't use:

cell.type_label.text"

In the following function:

-(void)tableView:(UITableView *) tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

Thanks, Dan.

like image 340
Supertecnoboff Avatar asked Dec 20 '22 00:12

Supertecnoboff


1 Answers

In the tableViewDidSelectRow all you need to do is:

UITableViewCellCustomClass *customCell = (UITableViewVellCustomClass*)[tableView cellForRowAtIndexPath:indexPath];

NSString *labelText = [[customCell type_label] text];

That should get you want you need.

like image 134
CW0007007 Avatar answered Dec 24 '22 11:12

CW0007007