From 18427b8500d856c84db2880554fda34cfb9a09ee Mon Sep 17 00:00:00 2001 From: Goktug Yilmaz Date: Sun, 6 Dec 2015 22:06:38 -0800 Subject: [PATCH] Added currentVCIndex, cancelStandardButtonEvents settings Fixed fatalError("init(coder:) has not been implemented") --- EZSwipeController.podspec | 2 +- EZSwipeController.swift | 90 +++++++++++++++++-------------- EZSwipeController/MySwipeVC.swift | 1 + README.md | 14 +++++ 4 files changed, 66 insertions(+), 41 deletions(-) diff --git a/EZSwipeController.podspec b/EZSwipeController.podspec index c390dd9..d1dfdc5 100644 --- a/EZSwipeController.podspec +++ b/EZSwipeController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "EZSwipeController" - s.version = "0.3" + s.version = "0.4" s.summary = "UIPageViewController like Snapchat/Tinder/iOS Main Pages" s.description = "Easy to use UIPageViewController to create a view navigation like Snapchat/Tinder/iOS Main Pages." s.homepage = "https://github.com/goktugyil/EZSwipeController" diff --git a/EZSwipeController.swift b/EZSwipeController.swift index a70876e..cff1f20 100644 --- a/EZSwipeController.swift +++ b/EZSwipeController.swift @@ -19,7 +19,7 @@ import UIKit } public class EZSwipeController: UIViewController { - + public struct Constants { public static var Orientation: UIInterfaceOrientation { get { @@ -61,52 +61,59 @@ public class EZSwipeController: UIViewController { public static let navigationBarHeight: CGFloat = 44 public static let lightGrayColor = UIColor(red: 248, green: 248, blue: 248, alpha: 1) } - + public var stackNavBars = [UINavigationBar]() public var stackVC: [UIViewController]! public var stackPageVC: [UIViewController]! public var stackStartLocation: Int! - + public var bottomNavigationHeight: CGFloat = 44 public var pageViewController: UIPageViewController! public var titleButton: UIButton? public var currentStackVC: UIViewController! + public var currentVCIndex: Int { + get { + return stackPageVC.indexOf(currentStackVC)! + } + } public var datasource: EZSwipeControllerDataSource? - + public var navigationBarShouldBeOnBottom = false public var navigationBarShouldNotExist = false - + public var cancelStandardButtonEvents = false + public init() { super.init(nibName: nil, bundle: nil) setupView() } - + public required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") + super.init(coder: aDecoder) + setupView() } - + private func setupDefaultNavigationBars(pageTitles: [String]) { guard navigationBarShouldNotExist == false else { return } - + var navBars = [UINavigationBar]() for index in 0.. UIViewController? { if viewController == stackPageVC.first { return nil } return stackPageVC[stackPageVC.indexOf(viewController)! - 1] } - + public func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -> UIViewController? { if viewController == stackPageVC.last { return nil } return stackPageVC[stackPageVC.indexOf(viewController)! + 1] } - + } extension EZSwipeController: UIPageViewControllerDelegate { - + public func pageViewController(pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) { if !completed { return } currentStackVC = stackPageVC[stackPageVC.indexOf(pageViewController.viewControllers!.first!)!] } - + } diff --git a/EZSwipeController/MySwipeVC.swift b/EZSwipeController/MySwipeVC.swift index e0cb3b8..38f0e9e 100644 --- a/EZSwipeController/MySwipeVC.swift +++ b/EZSwipeController/MySwipeVC.swift @@ -13,6 +13,7 @@ class MySwipeVC: EZSwipeController { datasource = self // navigationBarShouldBeOnBottom = true // navigationBarShouldNotExist = true +// cancelStandardButtonEvents = true } override func viewDidLoad() { diff --git a/README.md b/README.md index c67c7dc..b8ced8c 100644 --- a/README.md +++ b/README.md @@ -297,6 +297,20 @@ class MySwipeVC: EZSwipeController { +####Extra Settings + +``` swift +override func setupView() { + cancelStandardButtonEvents() + // Use this setting if you are using custom button that + // has nothing to do with swiping the viewcontroller +} +``` + +``` swift +self.currentVCIndex +//Use this to get the current page index +``` ##Requirements