3

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?

Jano
  • 62,815
  • 21
  • 164
  • 192
user964627
  • 655
  • 3
  • 14
  • 24

3 Answers3

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

Nekto
  • 17,837
  • 1
  • 55
  • 65
Rajat
  • 1,378
  • 4
  • 17
  • 33
1

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

user387184
  • 10,953
  • 12
  • 77
  • 147