Git Product home page Git Product logo

rkswipebetweenviewcontrollers's Introduction

RKSwipeBetweenViewControllers

UIPageViewController and custom UISegmentedControl synchronized and animated. Similar to Spotify's "My Music" section.

Please check the .h to see how to customize anything

Support

##Pod You should not use the pod in most cases, as they don't allow for customizability. I would recommend dragging the .h and .m files manually into your project

pod 'RKSwipeBetweenViewControllers'

##Updates, Questions, and Requests twitter <--- I am a very light twitterer, so I won't spam you

Demo:

(after five minutes of customization)

demo

Any number of any view controllers should technically work, though it doesn't look great with more than 4

Customizable!

Customizable!

(check the RKSwipeBetweenViewControllers.h for actual customizable features)

how to use

(check out the provided AppDelegate to see an example):

Programmatically (preferred)

  1. Import RKSwipeBetweenViewControllers.h

    #import <RKSwipeBetweenViewControllers/RKSwipeBetweenViewControllers.h>
  2. Initialize a UIPageViewController

    UIPageViewController *pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
  3. Initialize a RKSwipeBetweenViewControllers

    RKSwipeBetweenViewControllers *navigationController = [[RKSwipeBetweenViewControllers alloc]initWithRootViewController:pageController];
  4. Add all your ViewControllers (in order) to navigationController.viewControllerArray (try to keep it under 5)

    [navigationController.viewControllerArray addObjectsFromArray:@[viewController1, viewController2, viewController3]];
  5. Use the custom class (or call it as the first controller from app delegate: see below)

    self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
    self.window.rootViewController = navigationController;
    [self.window makeKeyAndVisible];

StoryBoard (do not use pods for this one)

  1. Drop the file into your project and import RKSwipeBetweenViewControllers.h

    #import RKSwipeBetweenViewControllers.h
  2. Embed a UIPageViewController inside a UINavigationController. Change the class of the to UINavigationController the custom class (RKSwipeBetweenViewControllers)

  3. change the transition style of the pageviewcontroller to scroll (click on the UIPageViewController in storyboard -> attributes inspector -> transition style -> scroll)

  4. go to the RKSwipeBetweenViewControllers.m file and use it as your own class now. Add your view controllers to "viewControllerArray". See below for various options.

    Programmatically, outside RKSwipeBetweenViewControllers.m (if this navigation bar isn't the first screen that comes up, or if you want to call it from the delegate)

    [customNavController.viewControllerArray addObjectsFromArray:@[viewController1, viewController2, viewController3]];

    Programmatically, inside RKSwipeBetweenViewControllers.m (most cases if your view controllers are programmatically created)

    [viewControllerArray addObjectsFromArray:@[demo,demo2]];

    storyboard, inside RKSwipeBetweenViewControllers.m (if your viewcontrollers are on the storyboard, but make sure to give them storyboard IDs)

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        UIViewController* theController = [storyboard instantiateViewControllerWithIdentifier:@"storyboardID"];
    
        [viewControllerArray addObject:theController];

    storyboard, outside RKSwipeBetweenViewControllers.m (if your viewcontrollers are on the storyboard, but make sure to give them storyboard IDs)

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        UIViewController* theController = [storyboard instantiateViewControllerWithIdentifier:@"storyboardID"];
    
        [theCustomViewController.viewControllerArray addObject:theController];

Any problems/questions? shoot me a pm

Areas for Improvement / Involvement

  • Working with horizontal layout
  • Working with more than 5 pages
  • Handful of infrequent bugs
  • Better performance when loading pages
  • Changing layout away from UINavigationController to allow the bar to be at the bottom
  • Bug: adding a MKMapView to a UIViewController in storyboard causes strange visual bug. Adding programmatically is fine
  • Crash on load for UITabBarControllers (resolved): cwRichardKim#15

rkswipebetweenviewcontrollers's People

Contributors

cwrichardkim avatar jeffreyjackson avatar

Watchers

583175259 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.