Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change textlabel in static cells in UITableView

I have a static UITableView, content of each cell I've made in storyboard, but I need to change texLabels of some cells programmatically while runtime. How can I do it?

like image 933
vZ10 Avatar asked May 23 '13 16:05

vZ10


1 Answers

Create a property for each cell you want to change in your table view controller, like so:

@property (weak) IBOutlet UITableViewCell *cell1;
@property (weak) IBOutlet UITableViewCell *cell2;

Connect each one to a cell in Interface Builder.

When you only need to change the label's text, you can use

self.cell1.textLabel.text = @"New Text";

If you need to replace the whole label, use

UILabel *newLabel = [[UILabel alloc] init];
self.cell2.textLabel = newLabel;
like image 107
Alyssa Ross Avatar answered Sep 21 '22 15:09

Alyssa Ross