回答編集履歴
1
UITableViewの基本的な書き方を追加
answer
CHANGED
@@ -1,1 +1,31 @@
|
|
1
|
+
回答が大きく変わるのでメインの部分を書き換えちゃいます。
|
2
|
+
まず、UITableViewCellをoutlet接続する必要ないのかなと思いいました。カスタムセルを作っているわけでもないようなのでデフォルトならばこのようなコードでテーブルビューを表現することができます。
|
3
|
+
|
4
|
+
```Swift
|
5
|
+
|
1
|
-
UIViewController
|
6
|
+
class ViewController: UIViewController,UITableViewDelegate, UITableViewDataSource {
|
7
|
+
|
8
|
+
@IBOutlet weak var tableView: UITableView!
|
9
|
+
//ここをCSVから読み込んだデータに書き換えてください.
|
10
|
+
let csvData = ["data1", "data2", "data3"]
|
11
|
+
|
12
|
+
override func viewDidLoad() {
|
13
|
+
tableView.delegate = self
|
14
|
+
tableView.dataSource = self
|
15
|
+
super.viewDidLoad()
|
16
|
+
}
|
17
|
+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
18
|
+
return csvData.count
|
19
|
+
}
|
20
|
+
|
21
|
+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
22
|
+
let cell = UITableViewCell(style: .default, reuseIdentifier: "cell")
|
23
|
+
cell.textLabel?.text = csvData[indexPath.row]
|
24
|
+
return cell
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
```
|
29
|
+
|
30
|
+
outlet接続しているのはStoryBoardに配置したUITableViewのみです。
|
31
|
+

|