【发布时间】:2011-05-24 07:02:53
【问题描述】:
我想在单击栏按钮项时更改 UITableView 的所有单元格的附件类型。对此有什么想法或代码。
【问题讨论】:
标签: iphone uitableview didselectrowatindexpath accessorytype
我想在单击栏按钮项时更改 UITableView 的所有单元格的附件类型。对此有什么想法或代码。
【问题讨论】:
标签: iphone uitableview didselectrowatindexpath accessorytype
只需拿一个标志(一个布尔值或其他东西)并在您的表格视图上调用 reloadData 。并在 cellForRowAtIndexPath 中测试您的标志并放置您想要的任何附件。
【讨论】:
在tableView:cellForRowAtIndexPath:,
...
if ( selected ) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
...
单击条形按钮项时,
...
selected = YES;
[self.tableView reloadRowsAtIndexPaths:[self.tableView visibleCells] withRowAnimation: UITableViewRowAnimationNone];
...
【讨论】:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// some code
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
您可以在其中检查您的状况并将电池的附件类型更改为具有以下任何值
typedef enum {
UITableViewCellAccessoryNone,
UITableViewCellAccessoryDisclosureIndicator,
UITableViewCellAccessoryDetailDisclosureButton,
UITableViewCellAccessoryCheckmark
} UITableViewCellAccessoryType;
【讨论】: