【问题标题】:How to customize uitableview如何自定义uitableview
【发布时间】:2009-05-20 22:54:04
【问题描述】:

如何自定义UITableView 中的每个单元格(就像每个单元格都有UITextfieldUIButton)?

【问题讨论】:

    标签: iphone cocoa-touch uitableview uikit


    【解决方案1】:

    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

    【讨论】:

      【解决方案2】:

      表格单元格中有一些子视图可以修改。我找到的好教程在这里:http://www.cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html

      【讨论】:

      • 我也想到了那个——经典教程。
      猜你喜欢
      • 2012-09-11
      • 1970-01-01
      • 1970-01-01
      • 2012-09-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-09
      相关资源
      最近更新 更多