質問編集履歴
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -84,4 +84,58 @@
|
|
84
84
|

|
85
85
|
|
86
86
|
エラーの原因がわかりません。
|
87
|
-
どのようにすればスワイプでも動くようになるのでしょうか?m(_ _)m
|
87
|
+
どのようにすればスワイプでも動くようになるのでしょうか?m(_ _)m
|
88
|
+
|
89
|
+
追記
|
90
|
+
```PageViewController
|
91
|
+
import UIKit
|
92
|
+
|
93
|
+
class PageViewController: UIPageViewController {
|
94
|
+
|
95
|
+
override func viewDidLoad() {
|
96
|
+
super.viewDidLoad()
|
97
|
+
// Do any additional setup after loading the view.
|
98
|
+
self.setViewControllers([getFirst()], direction: .forward, animated: true, completion: nil)
|
99
|
+
self.dataSource = self
|
100
|
+
}
|
101
|
+
|
102
|
+
func getFirst() -> FirstViewController {
|
103
|
+
return storyboard!.instantiateViewController(withIdentifier: "first") as! FirstViewController
|
104
|
+
}
|
105
|
+
|
106
|
+
func getSecond() -> SecondViewController {
|
107
|
+
return storyboard!.instantiateViewController(withIdentifier: "second") as! SecondViewController
|
108
|
+
}
|
109
|
+
|
110
|
+
func getThird() -> ThirdViewController {
|
111
|
+
return storyboard!.instantiateViewController(withIdentifier: "third") as! ThirdViewController
|
112
|
+
}
|
113
|
+
|
114
|
+
}
|
115
|
+
|
116
|
+
extension PageViewController : UIPageViewControllerDataSource {
|
117
|
+
|
118
|
+
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
|
119
|
+
|
120
|
+
if viewController.isKind(of: ThirdViewController.self) {
|
121
|
+
return getSecond()
|
122
|
+
} else if viewController.isKind(of: SecondViewController.self) {
|
123
|
+
return getFirst()
|
124
|
+
} else {
|
125
|
+
return nil
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
|
130
|
+
|
131
|
+
if viewController.isKind(of: FirstViewController.self) {
|
132
|
+
return getSecond()
|
133
|
+
} else if viewController.isKind(of: SecondViewController.self) {
|
134
|
+
return getThird()
|
135
|
+
} else {
|
136
|
+
return nil
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
}
|
141
|
+
```
|