【问题标题】:How can I add multiple cell.textLabel.text in Array?如何在数组中添加多个 cell.textLabel.text?
【发布时间】:2013-07-16 05:40:35
【问题描述】:

我在 UITableViewController 中使用了多个选择,如下所示。这是 UIAlertView 的委托方法,其中有 UIAlertView 包含 Table。

现在如何将特定选定的 indexPath.row 添加到我的数组中,如果有人取消选中它,则将其删除。

- (void)tableAlert:(SBTableAlert *)tableAlert didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSLog(@"MY INDEX PATH IS %@", indexPath);


if (tableAlert.type == SBTableAlertTypeMultipleSelct) {
    UITableViewCell *cell = [tableAlert.tableView cellForRowAtIndexPath:indexPath];
    if (cell.accessoryType == UITableViewCellAccessoryNone)
        [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
    else
        [cell setAccessoryType:UITableViewCellAccessoryNone];

    [tableAlert.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
}

【问题讨论】:

    标签: uitableview didselectrowatindexpath


    【解决方案1】:

    我很想创建一个用于 tableView 的项目字典。然后为字典中的每个对象都有一个“选定的”布尔属性。然后,您可以简单地将其设置为 true 或 false,并在点击警报视图时使用 [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];。如果您需要知道哪些对象的行被选中,您还可以枚举。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-11
      • 2014-04-10
      • 1970-01-01
      • 2014-09-11
      • 2014-06-09
      相关资源
      最近更新 更多