質問編集履歴
3
書式改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,5 +1,161 @@
|
|
1
|
-
|
1
|
+
。
|
2
2
|
|
3
|
-
|
3
|
+
### tableviewを表示したい
|
4
4
|
|
5
|
+
Swiftでtableviewを表示させたいのですが、どうしてもうまくいかないので見てもらいたいです。
|
6
|
+
|
7
|
+
エラーとかは何も出ていないのですが、ビルドしたとき何も画面に映らないです。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
### コード
|
12
|
+
|
13
|
+
ViewController
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
```ViewController
|
18
|
+
|
19
|
+
import UIKit
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
class ViewController : UIViewController,UITableViewDelegate,UITableViewDataSource{
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
@IBOutlet weak var TableView: UITableView!
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
/// 画像のファイル名
|
32
|
+
|
33
|
+
let imageNames = ["バルセロナ.jpg", "ナポリ.jpg", "リアルマドリード.jpg", "ガンバ大阪.jpg"]
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
/// 画像のタイトル
|
38
|
+
|
39
|
+
let imageTitles = ["バルセロナ", "ナポリ", "リアルマドリード", "ガンバ大阪"]
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
/// 画像の説明
|
44
|
+
|
45
|
+
let imageDescriptions = [
|
46
|
+
|
47
|
+
"ああああああああああああ",
|
48
|
+
|
49
|
+
"ああああああああああああ",
|
50
|
+
|
51
|
+
"ああああああああああああ",
|
52
|
+
|
53
|
+
"ああああああああああああ"
|
54
|
+
|
55
|
+
]
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
override func viewDidLoad() {
|
62
|
+
|
63
|
+
super.viewDidLoad()
|
64
|
+
|
65
|
+
// Do any additional setup after loading the view, typically from a nib.
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
override func didReceiveMemoryWarning() {
|
70
|
+
|
71
|
+
super.didReceiveMemoryWarning()
|
72
|
+
|
73
|
+
// Dispose of any resources that can be recreated.
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
/// セルの個数を指定するデリゲートメソッド(必須)
|
80
|
+
|
81
|
+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
82
|
+
|
83
|
+
return imageNames.count
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
/// セルに値を設定するデータソースメソッド(必須)
|
90
|
+
|
91
|
+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
92
|
+
|
93
|
+
//?
|
94
|
+
|
95
|
+
let cell = tableView.dequeueReusableCell(withIdentifier: "MyCell",for: indexPath) as! CustomCell
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
// セルに値を設定
|
100
|
+
|
101
|
+
cell.soccer_image.image = UIImage(named: imageNames[indexPath.row])
|
102
|
+
|
103
|
+
cell.teame_name.text = imageTitles[indexPath.row]
|
104
|
+
|
105
|
+
cell.reaage.text = imageDescriptions[indexPath.row]
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
return cell
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
CustomCell
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
```CustomCell
|
126
|
+
|
127
|
+
import UIKit
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
class CustomCell: UITableViewCell {
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
@IBOutlet weak var soccer_image: UIImageView!
|
136
|
+
|
137
|
+
@IBOutlet weak var teame_name: UILabel!
|
138
|
+
|
139
|
+
@IBOutlet weak var reaage: UILabel!
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
override func awakeFromNib() {
|
144
|
+
|
145
|
+
super.awakeFromNib()
|
146
|
+
|
147
|
+
// Initialization code
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
```
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
### 試したこと
|
156
|
+
|
157
|
+
classの指定、identifierの指定も行なっています。
|
158
|
+
|
159
|
+
画面になぜ表示されないのか、色々調べたのですが全部行なっていると思うので原因がわかりませんでした。
|
160
|
+
|
5
|
-
|
161
|
+
よろしくお願いします。
|
2
文
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[tableviewが表示されません](https://github.com/175atsu/Soccer_List)
|
2
2
|
|
3
|
-
|
3
|
+
↑githubです
|
4
4
|
|
5
5
|
見てもらえると助かります。
|
1
文
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,10 +1,4 @@
|
|
1
|
-
tableviewが表示されません
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
https://github.com/175atsu/Soccer_List
|
1
|
+
[tableviewが表示されません](https://github.com/175atsu/Soccer_List)
|
8
2
|
|
9
3
|
|
10
4
|
|