この記事について
| 環境 | 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;
}
