左と右のセルに情報を表示しようとすると問題が発生します。initWithStyle
withを使用していることは承知していUITableViewCellStyleSubtitle
ます。私はこれを使用していますが、うまくいかないようです。
サンプルコードは次のとおりです。
- (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;
}
cell.textLabel.text は問題なく表示できますが、単純な「価格」を表示することはできません。のフォントサイズを設定するなど、さまざまなことを試しましたcell.detailTextLabel
。
UITableViewCellStyleValue1
古い投稿でいくつかの人が提案したように、私も試しました。「価格」に設定した後に NSLog をスローすると、cell.detailTextLabel が null として表示されます。
私が間違っているのかわかりません。
編集:私はこれを見つけました: cell.detailTextLabel.text は NULL です
削除するif (cell == nil)
と機能します...そのチェックは適切に行われているはずですが、さまざまなスタイルを使用するときにどのように機能させますか?