Я делаю приложение с примерами с помощью раскадровки, чтобы иметь вид с UITableView
с UITableViewCell
, который осуществляет навигацию к другому UIView
.Использование alloc и init при использовании UITableViewCell из раскадровки
Так что нужно закодировать, чтобы заполнить ячейку на виде таблицы.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"SampleCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
NSLog(@"cai no init da cell");
}
GPItem *item = [self.items objectAtIndex:indexPath.row];
cell.textLabel.text = @"Post";
cell.detailTextLabel.text = item.imageURL;
return cell;
}
я понял, что код if (cell == nil) { ...
никогда не выполняет, так что я на самом деле нужно сделать, что использует ячейку из раскадровки?
Спасибо.
'UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: cellIdentifier];' это делает ячейку не ноль – nsgulliver