UITableViewCell initWithStyle: UITableViewCellStyleSubtitle nie działa
Mam problem z wyświetlaniem informacji w komórce, jednej po lewej i jednej po prawej. Mam świadomość używaniainitWithStyle
zUITableViewCellStyleSubtitle
. Używam tego, ale nie działa.
Oto przykładowy kod:
<code>- (UITableViewCell *)tableView:(UITableView *)ltableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Account Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:Cellidentifier]; } Accounts *account = [self.fetchedResultsController objectAtIndexPath]; cell.textLabel.text = account.name; cell.detailTextLabel.text = @"Price"; return cell; } </code>
Mogę dobrze wyświetlić cell.textLabel.text, jednak nie mogę wyświetlić prostej „ceny”. Próbowałem różnych rzeczy, takich jak ustawianie rozmiaru czcionkicell.detailTextLabel
.
Próbowałem teżUITableViewCellStyleValue1
jak niektórzy sugerowali w starszych postach. Rzut NSLog po ustawieniu na „Price”, pokazuje cell.detailTextLabel jako null.
Nie wiem, co robię źle.
Edytuj: znalazłem to:cell.detailTextLabel.text ma wartość NULL
Jeśli usunęif (cell == nil)
to działa ... To sprawdzenie powinno być na miejscu, więc jak sprawić, by działało przy użyciu różnych stylów?