質問編集履歴
3
add explain
test
CHANGED
File without changes
|
test
CHANGED
@@ -222,6 +222,8 @@
|
|
222
222
|
|
223
223
|
|
224
224
|
|
225
|
+
Segueを削除して新しくファイルを4つ作りそれぞれのViewに割り当てました。
|
226
|
+
|
225
227
|
[GyazoGIF参考動画](https://gyazo.com/63f1adec22cfd08fac21ae4628f9227c)
|
226
228
|
|
227
229
|
変更後
|
2
add video
test
CHANGED
File without changes
|
test
CHANGED
@@ -220,6 +220,10 @@
|
|
220
220
|
|
221
221
|
```
|
222
222
|
|
223
|
+
|
224
|
+
|
225
|
+
[GyazoGIF参考動画](https://gyazo.com/63f1adec22cfd08fac21ae4628f9227c)
|
226
|
+
|
223
227
|
変更後
|
224
228
|
|
225
229
|
```
|
1
add code
test
CHANGED
File without changes
|
test
CHANGED
@@ -219,3 +219,133 @@
|
|
219
219
|
|
220
220
|
|
221
221
|
```
|
222
|
+
|
223
|
+
変更後
|
224
|
+
|
225
|
+
```
|
226
|
+
|
227
|
+
import UIKit
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
private struct Segue {
|
232
|
+
|
233
|
+
var title = ""
|
234
|
+
|
235
|
+
let `class` : AnyClass
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
class FirstViewController: UIViewController {
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
@IBOutlet weak var tableView: UITableView!
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
private var segues: [Segue] = [
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
Segue(title: "aaaaaaaa", class: Segue0ViewController.self),
|
254
|
+
|
255
|
+
Segue(title: "bbbbbbbb", class: Segue1ViewController.self),
|
256
|
+
|
257
|
+
Segue(title: "cccccccc", class: Segue2ViewController.self),
|
258
|
+
|
259
|
+
Segue(title: "dddddddd", class: Segue3ViewController.self)
|
260
|
+
|
261
|
+
]
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
override func viewDidLoad() {
|
266
|
+
|
267
|
+
super.viewDidLoad()
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
self.tableView.rowHeight = 60
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
tableView.delegate = self
|
276
|
+
|
277
|
+
tableView.dataSource = self
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
}
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
extension FirstViewController: UITableViewDelegate {
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
let segue = self.segues[indexPath.row]
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
let vcClass = segue.class as! UIViewController.Type
|
300
|
+
|
301
|
+
let vc = vcClass.init()
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
self.navigationController?.pushViewController(vc, animated: true)
|
306
|
+
|
307
|
+
tableView.deselectRow(at: indexPath, animated: true)
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
}
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
extension FirstViewController: UITableViewDataSource {
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
322
|
+
|
323
|
+
return self.segues.count
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
|
334
|
+
|
335
|
+
let segue = self.segues[indexPath.row]
|
336
|
+
|
337
|
+
cell.textLabel?.text = segue.title
|
338
|
+
|
339
|
+
// cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
return cell
|
344
|
+
|
345
|
+
}
|
346
|
+
|
347
|
+
}
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
```
|