【问题标题】:Add buttons programmatically to table view cells [closed]以编程方式将按钮添加到表格视图单元格[关闭]
【发布时间】:2011-10-11 04:25:27
【问题描述】:

我可以在表格视图中添加和删除单元格。如何为每个添加的单元格设置两个按钮?

【问题讨论】:

    标签: ios uitableview uibutton


    【解决方案1】:

    将按钮添加为单元格的子视图。就是这样。我已经给出了样本:

    //Create your cell then do the following    
    UIButton *newBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [newBtn setFrame:CGRectMake(10,5,55,55)];
    [newBtn addTarget:self action:@selector(yourSelector:) forControlEvents:UIControlEventTouchUpInside];
    
    [cell addSubview:newBtn];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-18
      • 2016-01-08
      • 2020-10-16
      • 2016-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-26
      相关资源
      最近更新 更多