質問編集履歴

3

Tutorial2ViewControllerのソースをを追加しました。

2018/03/30 09:59

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -165,3 +165,69 @@
165
165
  }
166
166
 
167
167
  ```
168
+
169
+
170
+
171
+ Tutorial2ViewControllerのソースです。
172
+
173
+ main.storyboard上で該当のViewControllerと紐付けていますが、ソース上はなにもいじっていない状態です。
174
+
175
+
176
+
177
+ ```
178
+
179
+ import UIKit
180
+
181
+ import os.log
182
+
183
+
184
+
185
+ class Tutorial2ViewController: UIViewController {
186
+
187
+
188
+
189
+ override func viewDidLoad() {
190
+
191
+ super.viewDidLoad()
192
+
193
+
194
+
195
+ // Do any additional setup after loading the view.
196
+
197
+ }
198
+
199
+
200
+
201
+ override func didReceiveMemoryWarning() {
202
+
203
+ super.didReceiveMemoryWarning()
204
+
205
+ // Dispose of any resources that can be recreated.
206
+
207
+ }
208
+
209
+
210
+
211
+ /*
212
+
213
+ // MARK: - Navigation
214
+
215
+
216
+
217
+ // In a storyboard-based application, you will often want to do a little preparation before navigation
218
+
219
+ override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
220
+
221
+ // Get the new view controller using segue.destinationViewController.
222
+
223
+ // Pass the selected object to the new view controller.
224
+
225
+ }
226
+
227
+ */
228
+
229
+
230
+
231
+ }
232
+
233
+ ```

2

ソースなどを追加

2018/03/30 09:58

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -33,3 +33,135 @@
33
33
  遷移しないというより、タップイベントが発火していないように見えます。
34
34
 
35
35
  通常のUIViewControllerと同じようにstoryboardのボタンとViewController.swiftファイルのfuncを繋いだ(TouchUp Insideを使用)のですが、これではダメなのでしょうか?
36
+
37
+
38
+
39
+ ##追記:ソースなど
40
+
41
+ Storyboardです。
42
+
43
+ PageViewController(1番左)からViewController2つ(中央緑背景)を表示させています。
44
+
45
+ 2枚めのViewControllerからUIViewController(水色背景)に向かってpresent modallyで繋いでいます。
46
+
47
+ ![storyboard](d21dc6719b90eb0bfae0f85662d993b7.png)
48
+
49
+
50
+
51
+ PageViewControllerのソースです。
52
+
53
+ ```
54
+
55
+ import UIKit
56
+
57
+ import os.log
58
+
59
+
60
+
61
+ class TutorialPageViewController: UIPageViewController {
62
+
63
+
64
+
65
+ override func viewDidLoad() {
66
+
67
+ super.viewDidLoad()
68
+
69
+ self.setViewControllers([getFirst()], direction: .forward, animated: true, completion: nil)
70
+
71
+ self.dataSource = self
72
+
73
+ }
74
+
75
+
76
+
77
+ func getFirst() -> Tutorial1ViewController {
78
+
79
+ return storyboard!.instantiateViewController(withIdentifier: "Tutorial1ViewController") as! Tutorial1ViewController
80
+
81
+ }
82
+
83
+
84
+
85
+ func getSecond() -> Tutorial2ViewController {
86
+
87
+ return storyboard!.instantiateViewController(withIdentifier: "Tutorial2ViewController") as! Tutorial2ViewController
88
+
89
+ }
90
+
91
+
92
+
93
+ override func didReceiveMemoryWarning() {
94
+
95
+ super.didReceiveMemoryWarning()
96
+
97
+ // Dispose of any resources that can be recreated.
98
+
99
+ }
100
+
101
+
102
+
103
+ /*
104
+
105
+ // MARK: - Navigation
106
+
107
+
108
+
109
+ // In a storyboard-based application, you will often want to do a little preparation before navigation
110
+
111
+ override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
112
+
113
+ // Get the new view controller using segue.destinationViewController.
114
+
115
+ // Pass the selected object to the new view controller.
116
+
117
+ }
118
+
119
+ */
120
+
121
+
122
+
123
+ }
124
+
125
+
126
+
127
+ extension TutorialPageViewController : UIPageViewControllerDataSource {
128
+
129
+
130
+
131
+ func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
132
+
133
+
134
+
135
+ if viewController.isKind(of: Tutorial2ViewController.self) {
136
+
137
+ return getFirst()
138
+
139
+ } else {
140
+
141
+ return nil
142
+
143
+ }
144
+
145
+ }
146
+
147
+
148
+
149
+ func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
150
+
151
+
152
+
153
+ if viewController.isKind(of: Tutorial1ViewController.self) {
154
+
155
+ return getSecond()
156
+
157
+ } else {
158
+
159
+ return nil
160
+
161
+ }
162
+
163
+ }
164
+
165
+ }
166
+
167
+ ```

1

問題点の追記

2018/03/30 09:28

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -25,3 +25,11 @@
25
25
 
26
26
 
27
27
  なぜ遷移できないのか、遷移するにはどうしたら良いのか教えて下さい。
28
+
29
+
30
+
31
+ ##追記
32
+
33
+ 遷移しないというより、タップイベントが発火していないように見えます。
34
+
35
+ 通常のUIViewControllerと同じようにstoryboardのボタンとViewController.swiftファイルのfuncを繋いだ(TouchUp Insideを使用)のですが、これではダメなのでしょうか?