Custom UITableView



我已经成功制作了一个使用UITableView的iPhone应用程序。我想开始添加一些生活的应用程序。我如何自定义表?例如,更改单元格的高度、向单元格添加自定义图像、颜色等....

有什么好的建议吗?

试试这个教程

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/

您也可以查看apple自己的示例代码。

特别是tableViewSuite非常好,以一种清晰易懂的方式展示了所有的主要功能。

这也是苹果的最佳实践…

http://developer.apple.com/library/ios/文档/UIKit/引用/UITableView_Class/引用/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];
}

请尝试使用标签来覆盖表格单元格,通过自定义标签,您可以自定义表格单元格。

最新更新