我試圖切換accesoryType當選擇一個表格單元格/取消...的行爲應該是:自來水 - >設置accessoryType到UITableViewCellAccessoryCheckmark - >再次點擊電池 - >回滾到UITableViewCellAccessoryNone類型。 在我的控制器實現如下:如何在單元格選擇/取消選擇時正確切換UITableViewCell的accesoryType?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
...反正一次作爲UITableViewCellAccessoryCheckmark我無法把它還原回UITableViewCellAccessoryNone風格配置! 我也試着撥打:
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
,但不刪除對號......我該怎麼辦?
編輯:執行是好的,問題是在自定義的UITableViewCell子類...對不起:P
對於快速和骯髒的:'cell.accessoryType^= UITableViewCellAccessoryCheckmark' :) – 2014-10-25 06:10:26