You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simply include the file [EMPageViewController.swift](EMPageViewController/EMPageViewController.swift) into your project.
39
+
Simply include the file [EMPageViewController.swift](https://github.com/emalyak/EMPageViewController/blob/master/EMPageViewController/EMPageViewController.swift) into your project.
40
40
41
41
## Example usage / Demo
42
-
Learn how to use EMPageViewController in your project by cloning this repository and opening the Xcode project file *Greetings.xcodeproj* in [Examples/Greetings](Examples/Greetings). The code for initializing EMPageViewController and implementing its delegate and data source is located in [RootViewController.swift](Examples/Greetings/Greetings/RootViewController.swift).
42
+
Learn how to use EMPageViewController in your project by cloning this repository and opening the Xcode project file *Greetings.xcodeproj* in [Examples/Greetings](https://github.com/emalyak/EMPageViewController/blob/master/Examples/Greetings). The code for initializing EMPageViewController and implementing its delegate and data source is located in [RootViewController.swift](https://github.com/emalyak/EMPageViewController/blob/master/Examples/Greetings/Greetings/RootViewController.swift).
43
43
44
44
## Documentation
45
+
Full documentation is available on [CocoaDocs](http://cocoadocs.org/docsets/EMPageViewController)
`EMPageViewController` allows for page navigation through different view controllers, or "pages". View controllers can be navigated via swiping gestures, or called programmatically.
66
-
67
-
#### Properties
68
-
69
-
Properties for providing view controllers and receiving messages during navigation.
70
-
71
-
* * *
72
-
73
-
##### `dataSource`
74
-
75
-
The object that provides view controllers on an as-needed basis throughout the navigation of the page view controller. If the data source is `nil`, gesture based scrolling will be disabled and all view controllers must be provided through `selectViewController:direction:animated:completion:`.
76
-
77
-
**Important**
78
-
79
-
If you are using a data source, make sure you set `dataSource` before calling `selectViewController:direction:animated:completion:`
Sets the view controller that will be selected after the animation. This method is also used to provide the first view controller that will be selected in the page view controller. If a data source has been set, the view controllers before and after the selected view controller will also be loaded but not appear yet.
108
-
109
-
**Important**
110
-
111
-
If you are using a data source, make sure you set `dataSource` before calling `selectViewController:direction:animated:completion:`
`selectViewController` | The view controller to be selected
121
-
`direction` | The direction of the navigation and animation if applicable
122
-
`animated` | A Boolean whether or not to animate the transition
123
-
`completion` | A block that's called after the transition is finished. The block parameter `transitionSuccessful` is true if the transition to the selected view controller was completed successfully.
124
-
125
-
* * *
126
-
127
-
##### `scrollForwardAnimated:completion:`
128
-
129
-
Transitions to the view controller right of the currently selected view controller in a horizontal orientation, or below the currently selected view controller in a vertical orientation. Also described as going to the next page.
`animated` | A Boolean whether or not to animate the transition
139
-
`completion` | A block that's called after the transition is finished. The block parameter `transitionSuccessful` is `true` if the transition to the selected view controller was completed successfully. If `false`, the transition returned to the view controller it started from.
140
-
141
-
* * *
142
-
143
-
##### `scrollReverseAnimated:completion:`
144
-
145
-
Transitions to the view controller left of the currently selected view controller in a horizontal orientation, or above the currently selected view controller in a vertical orientation. Also described as going to the previous page.
`animated` | A Boolean whether or not to animate the transition
155
-
`completion` | A block that's called after the transition is finished. The block parameter `transitionSuccessful` is `true` if the transition to the selected view controller was completed successfully. If `false`, the transition returned to the view controller it started from.
156
-
157
-
* * *
158
-
159
-
### EMPageViewControllerDataSource
160
-
The `EMPageViewControllerDataSource` protocol is adopted to provide the view controllers that are displayed when the user scrolls through pages. Methods are called on an as-needed basis.
161
-
162
-
Each method returns a UIViewController object or `nil` if there are no view controllers to be displayed.
163
-
164
-
If the data source is `nil`, gesture based scrolling will be disabled and all view controllers must be provided through `selectViewController:direction:animated:completion:`.
Called to optionally return a view controller that is to the left of a given view controller in a horizontal orientation, or above a given view controller in a vertical orientation.
`viewController` | The point of reference view controller
182
-
183
-
**Return value**
184
-
185
-
The view controller that is to the left of the given `viewController` in a horizontal orientation, or above the given `viewController` in a vertical orientation, or `nil` if there is no view controller to be displayed.
`viewController` | The point of reference view controller
203
-
204
-
**Return value**
205
-
206
-
The view controller that is to the right of the given `viewController` in a horizontal orientation, or below the given `viewController` in a vertical orientation, or `nil` if there is no view controller to be displayed.
207
-
208
-
* * *
209
-
210
-
### EMPageViewControllerDelegate
211
-
212
-
The `EMPageViewControllerDelegate` protocol is adopted to receive messages for all major events of the page transition process.
This method will not be called if the start view controller is `nil`. A common scenario where this will occur is when you initialize the page view controller and use `selectViewController:direction:animated:completion:` to load the first controller.
`startViewController` | The currently selected view controller the transition is starting from
233
-
`destinationViewController` | The view controller being scrolled to where the transition will end
234
-
235
-
**Note**
236
-
If bouncing is enabled, it is possible this method will be called more than once for one page transition. It can be called before the initial scroll to the destination view controller (which is when it is usually called), and it can also be called when the scroll momentum carries over slightly to the view controller after the original destination view controller.
Called whenever there has been a scroll position change in a page transition. This method is very useful if you need to know the exact progress of the page transition animation.
243
-
244
-
This method will not be called if the start view controller is `nil`. A common scenario where this will occur is when you initialize the page view controller and use `selectViewController:direction:animated:completion:` to load the first controller.
`startViewController` | The currently selected view controller the transition is starting from
257
-
`destinationViewController` | The view controller being scrolled to where the transition will end
258
-
`progress` | The progress of the transition, where 0 is a neutral scroll position, >= 1 is a complete transition to the right view controller in a horizontal orientation, or the below view controller in a vertical orientation, and <= -1 is a complete transition to the left view controller in a horizontal orientation, or the above view controller in a vertical orientation. Values may be greater than 1 or less than -1 if the scroll velocity is quick enough.
`startViewController` | The currently selected view controller the transition is starting from
277
-
`destinationViewController` | The view controller that was been attempted to be selected
278
-
`transitionSuccessful` | A Boolean whether the transition to the destination view controller was successful or not. If `true`, the new selected view controller is `destinationViewController`. If `false`, the transition returned to the view controller it started from, so the selected view controller is `startViewController`.
Feedback? Suggestions? Just want to say hello? Contact me anytime on Twitter [@emalyak](https://twitter.com/emalyak). You can also visit my website [erikmalyak.com](http://erikmalyak.com) for other ways to get in touch.
0 commit comments