В моем представлении таблицы я пытаюсь использовать ячейку представления таблицы по умолчанию для большинства строк, но хочу использовать пользовательскую ячейку для одной строки. Проблема в том, что одна строка с пользовательской ячейкой. Я явно не загружаю его правильно, потому что я не могу получить доступ к свойствам пользовательской ячейки.Загрузка нескольких типов UITableViewCell
- (void)viewDidLoad {
[super viewDidLoad];
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
[self.tableView registerNib:[UINib nibWithNibName:@"KeepLoginCell" bundle:nil]
forCellReuseIdentifier:@"KeepLoginCell"];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = nil;
cell.backgroundColor = [UIColor clearColor];
cell.textLabel.textColor = [UIColor whiteColor];
if (indexPath.section == 0) {
cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"];
}
if (indexPath.row == 0) {
cell.textLabel.text = @"Recent Purchases";
}
} else if (indexPath.section == 1) {
cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"];
}
if (indexPath.row == 0) {
cell.textLabel.text = @"Payment Method";
}
} else if (indexPath.section == 2) {
if (indexPath.row == 0) {
cell = (KeepLoginCell *)[tableView dequeueReusableCellWithIdentifier:@"KeepLoginCell"];
if (!cell) {
cell = [[KeepLoginCell alloc]init];
}
} else if (indexPath.row == 1) {
cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"];
}
cell.textLabel.text = [self.settingsArray objectAtIndex:indexPath.row];
}
}
return cell;
}
Заполнение пользовательских ячеек и возвратных ячеек в инструкции if. –