0

我想在单击栏按钮项时更改 UITableView 的所有单元格的附件类型。对此有什么想法或代码。

4

3 回答 3

2

只需带一个标志(布尔或其他东西)并在您的表格视图上调用 reloadData 。并在 cellForRowAtIndexPath 中测试您的标志并放置您想要的任何附件。

于 2011-05-24T07:09:07.293 回答
1

tableView:cellForRowAtIndexPath:,

...
if ( selected ) {
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
...

单击条形按钮项时,

...
selected = YES;
[self.tableView reloadRowsAtIndexPaths:[self.tableView visibleCells] withRowAnimation: UITableViewRowAnimationNone];
...
于 2011-05-24T07:12:21.340 回答
0
- (UITableViewCell  *)tableView:(UITableView  *)tableView cellForRowAtIndexPath:(NSIndexPath  *)indexPath {
    // some code
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
    }

您可以在其中检查您的状况并将电池的附件类型更改为具有以下任何值

typedef enum {
   UITableViewCellAccessoryNone,
   UITableViewCellAccessoryDisclosureIndicator,
   UITableViewCellAccessoryDetailDisclosureButton,
   UITableViewCellAccessoryCheckmark
} UITableViewCellAccessoryType;
于 2011-05-24T07:11:12.760 回答