【Xcode】TableViewで画像とテキストを並べる

この記事について

環境Xcode、Objective-C
目的TableViewのセルに画像とテキストを並べて表示する
結果cell.imageView.imageに画像を設定するだけでいい

Xcode の TableView で画像とテキストを並べる表示をする Objective-C のスクリプト例

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
    
    //テキスト
    cell.textLabel.text = myArray[indexPath.row];

    //画像
    cell.imageView.image = [UIImage imageNamed:@"画像.gif"];
    
    return cell;
}

参考ページ

関連記事

タイトルとURLをコピーしました