views:

142

answers:

1

hi all,

i want to add 3 labels into a cell dynamically, cell is created dynamically as well. but i don't know how to create labels and add it into the cell in objective c (iphone). can anybody help me?

A: 

By "dynamically" I assume you mean via code, not via Interface Builder. I also assume you know how to use -tableView:cellForRowAtIndexPath:.

Then things are simple. The UITableViewCell has a readonly contentView property. You can just add your three UILabel's as a subview of contentView.

UIView* view = cell.contentView;
UILabel* label1 = [[UILabel alloc] initWithFrame:…];
…
[view addSubview:label1];
[label1 release];
…
KennyTM