【发布时间】:2009-05-20 22:54:04
【问题描述】:
如何自定义UITableView 中的每个单元格(就像每个单元格都有UITextfield 和UIButton)?
【问题讨论】:
标签: iphone cocoa-touch uitableview uikit
如何自定义UITableView 中的每个单元格(就像每个单元格都有UITextfield 和UIButton)?
【问题讨论】:
标签: iphone cocoa-touch uitableview uikit
UITableView 单元格响应选择 - 它在 tableView:didSelectRowAtIndexPath 中处理,也许这满足您的 UIButton 要求。如果您需要 UIButton,这应该不难——它只是另一个 UIView 组件。
Easy custom UITableView drawing是自定义UITableView的详细文章。它超出了您的要求,但您可能会发现有用的细节。查看 contentView 中的布局 部分,了解如何向单元格添加视图 - 该示例添加图像和文本(大量自定义背景内容正在发生)。
讨论的示例代码here:
UIView* container = [[UIView alloc] initWithFrame:goodRect];
UITableView* tv = [[UITableView alloc] initWithFrame:tableRect];
UIButton* btn = [[UIButton alloc] initWithFrame:btnFrame];
[container addSubview:tv];
[container addSubview:btn];
myController.view = container;
也许看看问题UIButton in a UITableView header ignores most touches。
【讨论】:
表格单元格中有一些子视图可以修改。我找到的好教程在这里:http://www.cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
【讨论】: