回答編集履歴
1
追記
test
CHANGED
@@ -39,3 +39,81 @@
|
|
39
39
|
|
40
40
|
|
41
41
|
```
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
おまけ
|
46
|
+
|
47
|
+
---
|
48
|
+
|
49
|
+
SecondViewにnumberプロパティを持たせたやり方
|
50
|
+
|
51
|
+
(1ファイル分(AppDelegate)影響範囲が狭まった)
|
52
|
+
|
53
|
+
```swift
|
54
|
+
|
55
|
+
// ViewController
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
let storyboard: UIStoryboard = self.storyboard!
|
64
|
+
|
65
|
+
let nextView = storyboard.instantiateViewController(withIdentifier: "second") as! SecondViewController
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
nextView.number = indexPath.row
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
self.present(nextView, animated: true, completion: nil)
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
```
|
82
|
+
|
83
|
+
```swift
|
84
|
+
|
85
|
+
class SecondViewController: UIViewController {
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
@IBOutlet weak var Label: UILabel!
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
var number:Int?
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
override func viewDidLoad() {
|
98
|
+
|
99
|
+
super.viewDidLoad()
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
// Do any additional setup after loading the view.
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
Label.text = "\(number)"
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
// 略
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
しかし、サイトがクソ重いな...
|