質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Q&A

解決済

1回答

786閲覧

UITableView セルに画像を表示させる

power

総合スコア12

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

0グッド

0クリップ

投稿2019/02/23 09:59

編集2019/02/25 09:38

現在、swiftで衣装リストを制作しております。
各セルにテキストだけでなく、それぞれの服の画像を表示させたいのですが、どのように記述すればいいのかがわかりません。
教えていただけますでしょうか?
よろしくお願いします。

イメージ説明

import UIKit let sectionTitle = ["ジャケット","スーツ・ベスト","トップス(長袖シャツ)"] let section0 = [("1、ジャケット","レディース"),("2、ジャケット","レディース"),("3、ジャケット","メンズ")] let section1 = [("1、スーツ","レディース"),("2、スーツ","レディース"),("3、スーツ","メンズ")] let section2 = [("1、長袖シャツ","レディース"),("2、長袖シャツ","レディース"),("3、長袖シャツ","レディース")] let tableData = [section0, section1, section2] class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { override func viewDidLoad() { super.viewDidLoad() let myTableView:UITableView! myTableView = UITableView(frame: view.frame, style: .grouped) myTableView.delegate = self myTableView.dataSource = self view.addSubview(myTableView) } func numberOfSections(in tableView: UITableView) -> Int { return sectionTitle.count } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { let sectionData = tableData[section] return sectionData.count } func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { return sectionTitle[section] } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = UITableViewCell(style: .subtitle, reuseIdentifier: "cell") let sectionData = tableData[(indexPath as NSIndexPath).section] let cellData = sectionData[(indexPath as NSIndexPath).row] cell.textLabel?.text = cellData.0 cell.detailTextLabel?.text = cellData.1 return cell } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let title = sectionTitle[indexPath.section] let sectionData = tableData[indexPath.section] let cellData = sectionData[indexPath.row] print("(title)(cellData.1)") print("(cellData.0)") } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } コード

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

Navigation Controllerを使用して作ることにしました。

投稿2019/03/10 09:42

power

総合スコア12

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問