Skip to content

Commit

Permalink
Merge pull request #8 from hyperoslo/fix/direction-bug
Browse files Browse the repository at this point in the history
Fix the direction from only going backwards
  • Loading branch information
Vadym Markov committed Apr 15, 2015
2 parents 12b1b33 + 76d3239 commit 8aa361f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Source/PagesController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,20 @@ import UIKit

delegate = self
dataSource = self
goto(startPage)
goTo(startPage)
}
}

// MARK: Public methods
extension PagesController {

public func goto(index: Int) {
if index > -1 && index < pages.count {
public func goTo(index: Int) {
if index >= 0 && index < pages.count {
let direction: UIPageViewControllerNavigationDirection = (index > currentIndex) ? .Forward : .Reverse
let viewController = pages[index]
currentIndex = index
setViewControllers([viewController],
direction: (index > currentIndex) ? .Forward : .Reverse,
direction: direction,
animated: true, completion: nil)
if setNavigationTitle {
title = viewController.title
Expand All @@ -52,11 +53,11 @@ extension PagesController {
}

public func next() {
goto(currentIndex + 1)
goTo(currentIndex + 1)
}

public func previous() {
goto(currentIndex - 1)
goTo(currentIndex - 1)
}

public func add(viewControllers: [UIViewController]) {
Expand Down

0 comments on commit 8aa361f

Please sign in to comment.