Я пытаюсь настроить UITableViewCell для "прикраски" приложения, и у меня возникают проблемы. Мой код:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UIImage *rowBackground;
UIImage *selectionBackground;
NSInteger sectionRows = [tableView numberOfRowsInSection:[indexPath section]];
NSInteger row = [indexPath row];
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if ( cell == nil ) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
if (row == 0 && row == sectionRows - 1) {
rowBackground = [UIImage imageNamed:@"topAndBottomRow.png"];
selectionBackground = [UIImage imageNamed:@"topAndBottomRowSelected.png"];
NSLog(@"topAndBottom");
}
else if ( row == 0 ) {
rowBackground = [UIImage imageNamed:@"topRow.png"];
selectionBackground = [UIImage imageNamed:@"topRowSelected.png"];
NSLog(@"topRow");
}
else if ( row == sectionRows - 1 ) {
rowBackground = [UIImage imageNamed:@"bottomRow.png"];
selectionBackground = [UIImage imageNamed:@"bottomRowSelected.png"];
NSLog(@"bottomRow");
} else {
rowBackground = [UIImage imageNamed:@"middleRow.png"];
selectionBackground = [UIImage imageNamed:@"middleRowSelected.png"];
NSLog(@"middleRow");
}
((UIImageView *)cell.backgroundView).image = rowBackground;
((UIImageView *)cell.selectedBackgroundView).image = selectionBackground;
NSString *cellValue = [[listOfItems objectAtIndex:indexPath.row] description];
cell.textLabel.text = cellValue;
return cell;
}
Он выбирает соответствующий образ, как показано в журнале консоли, но у меня есть две проблемы:
1. Установка (cell.backgroundView) .image не имеет никакого эффекта
2. Установка ошибок (cell.selectedBackgroundView) .image с помощью:
- [UITableViewCellSelectedBackground setImage:]: нераспознанный селектор, отправленный экземпляру 0x4b90670
Я могу найти подсказки о проблемах UIView с этим в Google, но не нашел ничего о UITableViewCell. Помощь