【问题标题】:Add a cell in a table view with a button and dynamic text在表格视图中添加一个带有按钮和动态文本的单元格
【发布时间】:2018-04-16 16:13:46
【问题描述】:

我有一个字符串,我想用一个按钮在表格视图中动态添加一个单元格,使用该字符串作为按钮的标题。

我找到了这段代码:

[self.array addObject:@"string"];
[self.tableView beginUpdates];
NSArray *arr = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:self.array.count-1 inSection:0]];
[self.tableView insertRowsAtIndexPaths:arr withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView endUpdates];

但它什么也没做。

【问题讨论】:

    标签: ios objective-c uitableview cocoa-touch row


    【解决方案1】:

    基本上,这应该可以完成工作。但您可能之前忘记了这样做:

    self.tableView.dataSource = self;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-08
      • 1970-01-01
      相关资源
      最近更新 更多