user964627
user964627

Reputation: 665

Custom UITableView

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

Answers (3)

Rajat
Rajat

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

user387184
user387184

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...

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITableView_Class/Reference/Reference.html

Upvotes: 1

Related Questions