0

インスペクターでセルスタイルをサブタイルに設定しましたが、まだ字幕はなく、空白ですが、ビューコントローラーのセクションにタイトルが表示されています。

  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{

UITableViewCell *cell = nil;

cell = [tableView dequeueReusableCellWithIdentifier:@"homeworkcell"];

if(cell == nil)
{
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault  reuseIdentifier:@"homeworkcell"];

}
cell.textLabel.text = [tabledata objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [tablesubtitles objectAtIndex:indexPath.row];
cell.textLabel.font = [UIFont systemFontOfSize:14.0];

 //static NSString *CellIdentifier = @"Cell";

  /* if (cell == nil) {
    cell = [[UITableViewCell alloc]
            initWithStyle:UITableViewCellStyleSubtitle
            reuseIdentifier:CellIdentifier];
  }*/

 // Configure the cell.
 //-----------------------------------------START----------------------------Set image of  cell----
  cellImage = [UIImage imageNamed:@"checkboxblank.png"];

 cell.imageView.image = cellImage;

 //--------------------------------------------END---------------------------end set image of cell--  

 return cell;

}
4

1 に答える 1

5

UITableViewCellStyleSubtitle新しい を作成するときはUITableViewCell、 ではなくを使用する必要がありますUITableViewCellStyleDefault。 はセル内のUITableViewCellStyleDefaultのみを表示し、 は表示しません。textLabeldetailTextLabel

UITableViewCellリファレンスの「セル スタイル」セクションと、「テーブル ビュー プログラミング ガイド」の「テーブル ビュー セルの標準スタイル」を参照してください。

于 2012-02-20T21:38:27.377 に答える