我有一个可用视图,但我想禁用某些单元格并保持其他单元格已启用。 我用下面的代码来禁用除了在cellForRowAtIndexPath
第一所有的细胞:更改uitableview中的特定单元格
if ([indexPath row] > 0) {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.userInteractionEnabled = NO;
cell.textLabel.textColor = [UIColor lightGrayColor];
}
但不是禁用所有细胞,使第一,它禁用所有的细胞,使最后。为什么会发生?我能做些什么来实现它的工作?
顺便说一句这是我所有的cellForRowAtIndexPath代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
sectionContents = [[self listOfItems] objectAtIndex:[indexPath section]];
contentsForThisRow = [sectionContents objectAtIndex:[indexPath row]];
if ([indexPath row] > 0) {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.userInteractionEnabled = NO;
cell.textLabel.textColor = [UIColor lightGrayColor];
}
static NSString *CellIdentifier = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = contentsForThisRow;
return cell;
}
将您所有的代码'cellForRowAtIndexPath:' – Nekto