У меня есть uitableview, но я хочу отключить некоторые ячейки и оставить другие включенными.Я использовал следующий код, чтобы отключить все ячейки, кроме первой в cellForRowAtIndexPath
:
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;
}