質問編集履歴
3
書式改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,3 +1,81 @@
|
|
1
|
+
。
|
2
|
+
### tableviewを表示したい
|
3
|
+
Swiftでtableviewを表示させたいのですが、どうしてもうまくいかないので見てもらいたいです。
|
4
|
+
エラーとかは何も出ていないのですが、ビルドしたとき何も画面に映らないです。
|
5
|
+
|
6
|
+
### コード
|
7
|
+
ViewController
|
8
|
+
|
9
|
+
```ViewController
|
10
|
+
import UIKit
|
11
|
+
|
12
|
+
class ViewController : UIViewController,UITableViewDelegate,UITableViewDataSource{
|
13
|
+
|
14
|
+
@IBOutlet weak var TableView: UITableView!
|
15
|
+
|
16
|
+
/// 画像のファイル名
|
17
|
+
let imageNames = ["バルセロナ.jpg", "ナポリ.jpg", "リアルマドリード.jpg", "ガンバ大阪.jpg"]
|
18
|
+
|
19
|
+
/// 画像のタイトル
|
20
|
+
let imageTitles = ["バルセロナ", "ナポリ", "リアルマドリード", "ガンバ大阪"]
|
21
|
+
|
22
|
+
/// 画像の説明
|
23
|
+
let imageDescriptions = [
|
24
|
+
"ああああああああああああ",
|
25
|
+
"ああああああああああああ",
|
26
|
+
"ああああああああああああ",
|
27
|
+
"ああああああああああああ"
|
28
|
+
]
|
29
|
+
|
30
|
+
|
31
|
+
override func viewDidLoad() {
|
32
|
+
super.viewDidLoad()
|
33
|
+
// Do any additional setup after loading the view, typically from a nib.
|
34
|
+
}
|
35
|
+
override func didReceiveMemoryWarning() {
|
36
|
+
super.didReceiveMemoryWarning()
|
37
|
+
// Dispose of any resources that can be recreated.
|
38
|
+
}
|
39
|
+
|
40
|
+
/// セルの個数を指定するデリゲートメソッド(必須)
|
1
|
-
|
41
|
+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
42
|
+
return imageNames.count
|
43
|
+
}
|
44
|
+
|
45
|
+
/// セルに値を設定するデータソースメソッド(必須)
|
46
|
+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
47
|
+
//?
|
48
|
+
let cell = tableView.dequeueReusableCell(withIdentifier: "MyCell",for: indexPath) as! CustomCell
|
49
|
+
|
50
|
+
// セルに値を設定
|
51
|
+
cell.soccer_image.image = UIImage(named: imageNames[indexPath.row])
|
52
|
+
cell.teame_name.text = imageTitles[indexPath.row]
|
53
|
+
cell.reaage.text = imageDescriptions[indexPath.row]
|
54
|
+
|
55
|
+
return cell
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
```
|
60
|
+
|
2
|
-
|
61
|
+
CustomCell
|
62
|
+
|
63
|
+
```CustomCell
|
64
|
+
import UIKit
|
65
|
+
|
66
|
+
class CustomCell: UITableViewCell {
|
67
|
+
|
68
|
+
@IBOutlet weak var soccer_image: UIImageView!
|
69
|
+
@IBOutlet weak var teame_name: UILabel!
|
70
|
+
@IBOutlet weak var reaage: UILabel!
|
71
|
+
|
72
|
+
override func awakeFromNib() {
|
73
|
+
super.awakeFromNib()
|
74
|
+
// Initialization code
|
75
|
+
}
|
76
|
+
```
|
77
|
+
|
78
|
+
### 試したこと
|
79
|
+
classの指定、identifierの指定も行なっています。
|
80
|
+
画面になぜ表示されないのか、色々調べたのですが全部行なっていると思うので原因がわかりませんでした。
|
3
|
-
|
81
|
+
よろしくお願いします。
|
2
文
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
[tableviewが表示されません](https://github.com/175atsu/Soccer_List)
|
2
|
-
|
2
|
+
↑githubです
|
3
3
|
見てもらえると助かります。
|
1
文
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
tableviewが表示されません
|
1
|
+
[tableviewが表示されません](https://github.com/175atsu/Soccer_List)
|
2
2
|
|
3
|
-
|
4
|
-
https://github.com/175atsu/Soccer_List
|
5
|
-
|
6
3
|
見てもらえると助かります。
|