<commit_before># EMPageViewController

![EMPageViewController Demo](greetings-demo.gif)

## A better page view controller for iOS
EMPageViewController is a full replacement for UIPageViewController with the features and predictability you’ve always wanted from a page view controller.

### Delegate messages every step of the way
EMPageViewController gives your delegate messages for every step of the page transition process: before, during, and after. This makes it very easy for you to incorporate animations or any other events that are highly dependent on the progress of transitioning a page.

### Convenient navigation methods
In addition to the ability scroll to any view controller, you can also easily scroll to the next or previous page without gestures if your app has navigation buttons.

### Written in Swift
EMPageViewController is not a subclass of UIPageViewController. Instead, it's a subclass of UIViewController with a UIScrollView, written in Swift, and it has common sense delegate and data source methods that will make the development of your page-based iOS app a breeze.

## Compatibility
* Xcode 6.1+
* iOS 7+
* iPhone, iPad, and iPod Touch

## Installation
Simply include [EMPageViewController.swift](EMPageViewController.swift) into your project.

## Demo
To see EMPageViewController in action, clone this repository, open the Xcode project file *Greetings.xcodeproj* in [Examples/Greetings](Examples/Greetings), and build and run the project.

## Usage

### Initialization

Initialize EMPageViewController and set its `dataSource` and `delegate` properties.

```swift
let pageViewController = EMPageViewController()
pageViewController.dataSource = self
pageViewController.delegate = self
```

You'll also need to adopt the `EMPageViewControllerDataSource` and `EMPageViewControllerDelegate` protocols. Instructions on how to conform to these protocols later.
```swift
class ViewControllerSubclass: UIViewController, EMPageViewControllerDataSource, EMPageViewControllerDelegate ...
...
```

Set the initial view controller for the page view controller with `selectViewController:direction:animated:completion:`. This is the page that will be selected when your view controller loads.
```swift
let initialViewController = MyViewController() // You'll probably have a method here that returns your view controller based on an index value or something similar, like viewControllerAtIndex:
pageViewController.selectViewController(currentViewController, direction: .Forward, animated: false, completion: nil)
```

Add EMPageViewController as a child view controller and subview to the UIViewController and UIView it will reside in.
```swift
self.addChildViewController(pageViewController)
self.view.addSubview(pageViewController)
pageViewController.didMoveToParentViewController(self)
```

Lastly, don't forget to set your newly created EMPageViewController object to a property in your UIViewController subclass to it's retained for use later on.

```swift
self.pageViewController = pageViewController
```


## Documentation
<commit_msg>Demo instructions, added table of contents<commit_after># EMPageViewController

![EMPageViewController Demo](greetings-demo.gif)

## A better page view controller for iOS
EMPageViewController is a full replacement for UIPageViewController with the features and predictability you’ve always wanted from a page view controller.

### Delegate messages every step of the way
EMPageViewController gives your delegate messages for every step of the page transition process: before, during, and after. This makes it very easy for you to incorporate animations or any other events that are highly dependent on the progress of transitioning a page.

### Convenient navigation methods
In addition to the ability scroll to any view controller, you can also easily scroll to the next or previous page without gestures if your app has navigation buttons.

### Written in Swift
EMPageViewController is not a subclass of UIPageViewController. Instead, it's a subclass of UIViewController with a UIScrollView, written in Swift, and it has common sense delegate and data source methods that will make the development of your page-based iOS app a breeze.

## Compatibility
* Xcode 6.1+
* iOS 7+
* iPhone, iPad, and iPod Touch

## Installation
Simply include [EMPageViewController.swift](EMPageViewController.swift) into your project.

## Example usage / Demo
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).

## Documentation

* [EMPageViewController](#empageviewcontroller-1)
  * [Properties](#properties)
    * [dataSource](#datasource)
    * [delegate](#delegate)
  * [Methods](#methods)
    * [selectViewController:direction:animated:completion:](#selectviewcontrollerdirectionanimatedcompletion)
    * [scrollForwardAnimated:completion:](#scrollforwardanimatedcompletion)
    * [scrollReverseAnimated:completion:](#scrollreverseanimatedcompletion)

* [EMPageViewControllerDataSource](#empageviewcontrollerdatasource)
  * [em_pageViewController:viewControllerLeftOfViewController:](#em_pageviewcontrollerviewcontrollerleftofviewcontroller)
  * [em_pageViewController:viewControllerRightOfViewController:](#em_pageviewcontrollerviewcontrollerrightofviewcontroller)

* [EMPageViewControllerDelegate](#empageviewcontrollerdelegate)
  * [em_pageViewController:willStartScrollingFrom:destinationViewController:](#em_pageviewcontrollerwillstartscrollingfromdestinationviewcontroller)
  * [em_pageViewController:isScrollingFrom:destinationViewController:progress:](#em_pageviewcontrollerisscrollingfromdestinationviewcontrollerprogress)
  * [em_pageViewController:didFinishScrollingFrom:selectedViewController:transitionSuccessful:](#em_pageviewcontrollerdidfinishscrollingfromselectedviewcontrollertransitionsuccessful)

{'fraction_non_alphanumeric': 0.061955628594905506, 'fraction_numerical': 0.0011503697617091207, 'mean_word_length': 6.945169712793733, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2666748', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1403, 'n_words': 581}