Reputation: 665
I have successfully made a iPhone app that uses a UITableView. I would like to start adding some life to the app. How do I customize the table? For example, change the height of the cells, add custom images to the cell, color, and So on....
Any good advice?
Upvotes: 3
Views: 5486
Reputation: 1388
UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UILabel *label;
label = [[[UILabel alloc] initWithFrame:CGRectMake(5, 0.5, 240.0, 25.0)] autorelease];
label.tag = WHAT_TAG;
label.font = [UIFont boldSystemFontOfSize:14.0];
label.textAlignment = UITextAlignmentLeft;
label.textColor = [UIColor blueColor];
label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
label.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:label];
}
Just try this use a label to overwrite the table cell and by customizing the label you can customize the tabel cell. Hope it helps...
Upvotes: 1
Reputation: 11053
You may also check Apples own sample code.
Especially the tableViewSuite is very nice and demonstrates all the main features in a clear understandable way.
It also shows best practice from Apple...
Upvotes: 1