2

コマンド cell.textLabel.text および cell.detailTextLabel.text はコンソールに出力を提供していますが、シミュレーターのテーブルビューには値がありません...

これは、私が使用したセルを生成するためのコードです..

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"bookCell";
    UITableViewCell *cell;
    cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];

  // Book *bookDetail=[booksArrayDataSource objectAtIndex:indexPath.row];


    cell.accessoryType=UITableViewCellAccessoryDetailDisclosureButton;

    cell.textLabel.text= [self titleForRow:indexPath];
    NSLog(@"title for row= %@", cell.textLabel.text);

    cell.detailTextLabel.text= [self subtitleForRow:indexPath];
    NSLog(@"subtitle for row= %@",cell.detailTextLabel.text);

    return cell;
}
4

2 に答える 2

0

ストーリーボード/xib に移動し、セル タイプをダイナミックからサブタイトルに変更します。

ここにあるものは何でも実行されません:

if (cell == nil)
{
...
}
于 2013-09-10T09:33:02.303 に答える
-2

セルに文字列値をロードする場合は、次のステートメントを使用します。

cell.textLabel.text =[[YOURArray_Name objectAtIndex:indexPath.row] stringValue]; (or)
cell.textLabel.text =[[YOURArray_Name objectAtIndex:indexPath.row] description];

セルに整数値をロードする場合は、次のステートメントを使用します。

cell.textLabel.text =[[YOURArray_Name objectAtIndex:indexPath.row] integerValue];

セルに Float 値をロードする場合は、次のステートメントを使用します。

cell.textLabel.text =[[YOURArray_Name objectAtIndex:indexPath.row] floatValue];
于 2013-09-10T05:59:44.180 に答える