所以,有一個問題:當我檢查表格中的單元格時,另一個單元格也檢查,但我只想在一次檢查。有源:多次檢查一次accesoryType
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = [[self.symptoms objectAtIndex:indexPath.row ] objectForKey:@"name"];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(indexPath);
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
cell.accessoryType = UITableViewCellAccessoryNone;
} else {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
有一個錯字:'tableView:di:'應該讀'tableView:didSelectRowAtIndexPath:'。 – Costique 2012-04-16 14:27:08
Costique沒有幫助:( – Hurrit 2012-04-16 14:39:42