开发者

Custom UITableView

开发者 https://www.devze.com 2023-04-08 23:35 出处:网络
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

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

An开发者_运维知识库y good advice?


try this tutorial

http://www.aboutobjects.com/tutorials.html

http://adeem.me/blog/2009/05/24/iphone-sdk-tutorial-part-4-tips-for-uitableview-design-change-design-add-header-footer-add-background-images-tips/


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消