質問編集履歴
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -171,3 +171,111 @@
|
|
171
171
|
エラーの原因がわかりません。
|
172
172
|
|
173
173
|
どのようにすればスワイプでも動くようになるのでしょうか?m(_ _)m
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
追記
|
178
|
+
|
179
|
+
```PageViewController
|
180
|
+
|
181
|
+
import UIKit
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
class PageViewController: UIPageViewController {
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
override func viewDidLoad() {
|
190
|
+
|
191
|
+
super.viewDidLoad()
|
192
|
+
|
193
|
+
// Do any additional setup after loading the view.
|
194
|
+
|
195
|
+
self.setViewControllers([getFirst()], direction: .forward, animated: true, completion: nil)
|
196
|
+
|
197
|
+
self.dataSource = self
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
func getFirst() -> FirstViewController {
|
204
|
+
|
205
|
+
return storyboard!.instantiateViewController(withIdentifier: "first") as! FirstViewController
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
func getSecond() -> SecondViewController {
|
212
|
+
|
213
|
+
return storyboard!.instantiateViewController(withIdentifier: "second") as! SecondViewController
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
func getThird() -> ThirdViewController {
|
220
|
+
|
221
|
+
return storyboard!.instantiateViewController(withIdentifier: "third") as! ThirdViewController
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
extension PageViewController : UIPageViewControllerDataSource {
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
if viewController.isKind(of: ThirdViewController.self) {
|
240
|
+
|
241
|
+
return getSecond()
|
242
|
+
|
243
|
+
} else if viewController.isKind(of: SecondViewController.self) {
|
244
|
+
|
245
|
+
return getFirst()
|
246
|
+
|
247
|
+
} else {
|
248
|
+
|
249
|
+
return nil
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
if viewController.isKind(of: FirstViewController.self) {
|
262
|
+
|
263
|
+
return getSecond()
|
264
|
+
|
265
|
+
} else if viewController.isKind(of: SecondViewController.self) {
|
266
|
+
|
267
|
+
return getThird()
|
268
|
+
|
269
|
+
} else {
|
270
|
+
|
271
|
+
return nil
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
```
|