UITableViewCell initWithStyle: UITableViewCellStyleSubtitle não está funcionando
Estou tendo um problema ao tentar exibir informações em uma célula, uma à esquerda e outra à direita. Estou ciente usandoinitWithStyle
comUITableViewCellStyleSubtitle
. Eu uso isso, mas não parece funcionar.
Aqui está um código de amostra:
<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>
Eu posso exibir cell.textLabel.text muito bem, no entanto não consigo obter o simples "Preço" a ser exibido. Eu tentei coisas diferentes, como definir o tamanho da fonte decell.detailTextLabel
.
Eu também tenteiUITableViewCellStyleValue1
como alguns sugeriram em posts mais antigos. Arremessou NSLog depois de definir para "Preço", mostra cell.detailTextLabel como nulo.
Não tenho certeza do que estou fazendo de errado.
Edit: Eu encontrei isto:cell.detailTextLabel.text é NULL
Se eu removerif (cell == nil)
Funciona ... Essa verificação deve estar no lugar, então como você faz o trabalho ao usar os diferentes estilos?