質問編集履歴
2
書式の再改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,230 +8,226 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
+
|
12
|
+
|
13
|
+
エラーメッセージ
|
14
|
+
|
15
|
+
ビルド自体は成功しますが、セルをタップしても画面遷移しません
|
16
|
+
|
11
17
|
```
|
12
18
|
|
13
|
-
エラーメッセージ
|
14
|
-
|
15
|
-
ビルド自体は成功しますが、セルをタップしても画面遷移しません
|
16
|
-
|
17
|
-
|
18
|
-
|
19
19
|
###該当のソースコード
|
20
20
|
|
21
|
+
|
22
|
+
|
23
|
+
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
private let myItems: NSArray = ["TEST1", "TEST2", "TEST3","TEST4"]
|
28
|
+
|
29
|
+
private var myTableView: UITableView!
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
override func viewDidLoad() {
|
34
|
+
|
35
|
+
super.viewDidLoad()
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
let barHeight: CGFloat = UIApplication.shared.statusBarFrame.size.height
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
let displayWidth: CGFloat = self.view.frame.width
|
44
|
+
|
45
|
+
let displayHeight: CGFloat = self.view.frame.height
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
myTableView = UITableView(frame: CGRect(x: 0, y: barHeight, width: displayWidth, height: displayHeight - barHeight))
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
myTableView.register(UITableViewCell.self, forCellReuseIdentifier: "MyCell")
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
myTableView.dataSource = self
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
myTableView.delegate = self
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
self.view.addSubview(myTableView)
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
override func didReceiveMemoryWarning() {
|
72
|
+
|
73
|
+
super.didReceiveMemoryWarning()
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
private func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: IndexPath) {
|
82
|
+
|
83
|
+
//print("Num: (indexPath.row)")
|
84
|
+
|
85
|
+
//print("Value: (myItems[indexPath.row])")
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
tableView.deselectRow(at: indexPath, animated: true)
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
self.present(SecondViewController(), animated: true, completion: nil)
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
104
|
+
|
105
|
+
return myItems.count
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
let cell = tableView.dequeueReusableCell(withIdentifier: "MyCell", for: indexPath as IndexPath)
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
cell.textLabel!.text = "(myItems[indexPath.row])"
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
return cell
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
class SecondViewController: UIViewController {
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
override func viewDidLoad() {
|
140
|
+
|
141
|
+
super.viewDidLoad()
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
self.view.backgroundColor = UIColor.white
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
let backButton:UIButton = UIButton()
|
150
|
+
|
151
|
+
backButton.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
|
152
|
+
|
153
|
+
backButton.setTitle("back", for: .normal)
|
154
|
+
|
155
|
+
backButton.setTitleColor(UIColor.blue, for: .normal)
|
156
|
+
|
157
|
+
backButton.layer.position = CGPoint(x: self.view.frame.width/2, y: self.view.frame.height/2)
|
158
|
+
|
159
|
+
backButton.addTarget(self, action: #selector(back), for: .touchUpInside)
|
160
|
+
|
161
|
+
self.view.addSubview(backButton)
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
@objc func back(){
|
168
|
+
|
169
|
+
self.dismiss(animated: true, completion: nil)
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
override func didReceiveMemoryWarning() {
|
174
|
+
|
175
|
+
super.didReceiveMemoryWarning()
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
class SecondViewController: UIViewController {
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
override func viewDidLoad() {
|
186
|
+
|
187
|
+
super.viewDidLoad()
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
self.view.backgroundColor = UIColor.white
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
let backButton:UIButton = UIButton()
|
196
|
+
|
197
|
+
backButton.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
|
198
|
+
|
199
|
+
backButton.setTitle("back", for: .normal)
|
200
|
+
|
201
|
+
backButton.setTitleColor(UIColor.blue, for: .normal)
|
202
|
+
|
203
|
+
backButton.layer.position = CGPoint(x: self.view.frame.width/2, y: self.view.frame.height/2)
|
204
|
+
|
205
|
+
backButton.addTarget(self, action: #selector(back), for: .touchUpInside)
|
206
|
+
|
207
|
+
self.view.addSubview(backButton)
|
208
|
+
|
209
|
+
}
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
@objc func back(){
|
214
|
+
|
215
|
+
self.dismiss(animated: true, completion: nil)
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
override func didReceiveMemoryWarning() {
|
220
|
+
|
221
|
+
super.didReceiveMemoryWarning()
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
|
21
229
|
```
|
22
230
|
|
23
|
-
|
24
|
-
|
25
|
-
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
private let myItems: NSArray = ["TEST1", "TEST2", "TEST3","TEST4"]
|
30
|
-
|
31
|
-
private var myTableView: UITableView!
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
override func viewDidLoad() {
|
36
|
-
|
37
|
-
super.viewDidLoad()
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
let barHeight: CGFloat = UIApplication.shared.statusBarFrame.size.height
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
let displayWidth: CGFloat = self.view.frame.width
|
46
|
-
|
47
|
-
let displayHeight: CGFloat = self.view.frame.height
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
myTableView = UITableView(frame: CGRect(x: 0, y: barHeight, width: displayWidth, height: displayHeight - barHeight))
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
myTableView.register(UITableViewCell.self, forCellReuseIdentifier: "MyCell")
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
myTableView.dataSource = self
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
myTableView.delegate = self
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
self.view.addSubview(myTableView)
|
68
|
-
|
69
|
-
}
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
override func didReceiveMemoryWarning() {
|
74
|
-
|
75
|
-
super.didReceiveMemoryWarning()
|
76
|
-
|
77
|
-
}
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
private func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: IndexPath) {
|
84
|
-
|
85
|
-
//print("Num: (indexPath.row)")
|
86
|
-
|
87
|
-
//print("Value: (myItems[indexPath.row])")
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
tableView.deselectRow(at: indexPath, animated: true)
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
self.present(SecondViewController(), animated: true, completion: nil)
|
98
|
-
|
99
|
-
}
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
106
|
-
|
107
|
-
return myItems.count
|
108
|
-
|
109
|
-
}
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
let cell = tableView.dequeueReusableCell(withIdentifier: "MyCell", for: indexPath as IndexPath)
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
cell.textLabel!.text = "(myItems[indexPath.row])"
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
return cell
|
126
|
-
|
127
|
-
}
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
}
|
132
|
-
|
133
|
-
```
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
```
|
138
|
-
|
139
|
-
class SecondViewController: UIViewController {
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
override func viewDidLoad() {
|
144
|
-
|
145
|
-
super.viewDidLoad()
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
self.view.backgroundColor = UIColor.white
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
let backButton:UIButton = UIButton()
|
154
|
-
|
155
|
-
backButton.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
|
156
|
-
|
157
|
-
backButton.setTitle("back", for: .normal)
|
158
|
-
|
159
|
-
backButton.setTitleColor(UIColor.blue, for: .normal)
|
160
|
-
|
161
|
-
backButton.layer.position = CGPoint(x: self.view.frame.width/2, y: self.view.frame.height/2)
|
162
|
-
|
163
|
-
backButton.addTarget(self, action: #selector(back), for: .touchUpInside)
|
164
|
-
|
165
|
-
self.view.addSubview(backButton)
|
166
|
-
|
167
|
-
}
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
@objc func back(){
|
172
|
-
|
173
|
-
self.dismiss(animated: true, completion: nil)
|
174
|
-
|
175
|
-
}
|
176
|
-
|
177
|
-
override func didReceiveMemoryWarning() {
|
178
|
-
|
179
|
-
super.didReceiveMemoryWarning()
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
}
|
184
|
-
|
185
|
-
class SecondViewController: UIViewController {
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
override func viewDidLoad() {
|
190
|
-
|
191
|
-
super.viewDidLoad()
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
self.view.backgroundColor = UIColor.white
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
let backButton:UIButton = UIButton()
|
200
|
-
|
201
|
-
backButton.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
|
202
|
-
|
203
|
-
backButton.setTitle("back", for: .normal)
|
204
|
-
|
205
|
-
backButton.setTitleColor(UIColor.blue, for: .normal)
|
206
|
-
|
207
|
-
backButton.layer.position = CGPoint(x: self.view.frame.width/2, y: self.view.frame.height/2)
|
208
|
-
|
209
|
-
backButton.addTarget(self, action: #selector(back), for: .touchUpInside)
|
210
|
-
|
211
|
-
self.view.addSubview(backButton)
|
212
|
-
|
213
|
-
}
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
@objc func back(){
|
218
|
-
|
219
|
-
self.dismiss(animated: true, completion: nil)
|
220
|
-
|
221
|
-
}
|
222
|
-
|
223
|
-
override func didReceiveMemoryWarning() {
|
224
|
-
|
225
|
-
super.didReceiveMemoryWarning()
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
}
|
230
|
-
|
231
|
-
```
|
232
|
-
|
233
|
-
|
234
|
-
|
235
231
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
236
232
|
|
237
233
|
Swift4
|
1
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,9 +18,9 @@
|
|
18
18
|
|
19
19
|
###該当のソースコード
|
20
20
|
|
21
|
-
```
|
21
|
+
```
|
22
|
-
|
23
|
-
|
22
|
+
|
23
|
+
|
24
24
|
|
25
25
|
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
26
26
|
|
@@ -130,11 +130,11 @@
|
|
130
130
|
|
131
131
|
}
|
132
132
|
|
133
|
-
|
133
|
+
```
|
134
|
+
|
135
|
+
|
136
|
+
|
134
|
-
|
137
|
+
```
|
135
|
-
|
136
|
-
|
137
|
-
|
138
138
|
|
139
139
|
class SecondViewController: UIViewController {
|
140
140
|
|
@@ -144,10 +144,6 @@
|
|
144
144
|
|
145
145
|
super.viewDidLoad()
|
146
146
|
|
147
|
-
|
148
|
-
|
149
|
-
// Do any additional setup after loading the view.
|
150
|
-
|
151
147
|
|
152
148
|
|
153
149
|
self.view.backgroundColor = UIColor.white
|
@@ -182,7 +178,7 @@
|
|
182
178
|
|
183
179
|
super.didReceiveMemoryWarning()
|
184
180
|
|
185
|
-
|
181
|
+
|
186
182
|
|
187
183
|
}
|
188
184
|
|
@@ -194,10 +190,6 @@
|
|
194
190
|
|
195
191
|
super.viewDidLoad()
|
196
192
|
|
197
|
-
|
198
|
-
|
199
|
-
// Do any additional setup after loading the view.
|
200
|
-
|
201
193
|
|
202
194
|
|
203
195
|
self.view.backgroundColor = UIColor.white
|
@@ -232,15 +224,11 @@
|
|
232
224
|
|
233
225
|
super.didReceiveMemoryWarning()
|
234
226
|
|
235
|
-
|
227
|
+
|
236
|
-
|
228
|
+
|
237
|
-
}
|
229
|
+
}
|
238
|
-
|
239
|
-
|
240
|
-
|
230
|
+
|
241
|
-
|
231
|
+
```
|
242
|
-
|
243
|
-
課題に対してアプローチしたことを記載してください
|
244
232
|
|
245
233
|
|
246
234
|
|