Code Monkey home page Code Monkey logo

crossnavigation's Introduction

CrossNavigation

if you inherit your view controllers from CNViewController, you'll be able to push them to the stack not just to right side (as you do if you use UINavigationController), but to any of four: left, top, right, bottom. Supports autorotations.

Usage

You can make a transition in code

XXViewController *nextViewController = ...;
[self presentViewController:nextViewController direction:CNDirectionTop animated:YES];

If at least two controllers are in the stack, users can drag back to return interactively to the previous screen (like UINavigationController). Or you can do the same in code (but obviously without interactivity):

[nextViewController dismissViewControllerAnimated:YES completion:^{ ... }];

This is UIViewController's method which was overridden.

  • Override
- (void)viewIsAppearing:(CGFloat)percentComplete { ... }

method in CNViewController subclass to be notified what is the current rate of a visible part of the screen. This method fires during transitions (both, interactive and noninteractive).

  • Override
- (BOOL)shouldAutotransitToDirection:(CNDirection)direction present:(BOOL)present { ... }

to take a control over interactive transitions. You may allow them or prohibit depends on your app's logic. present parameter is YES if a considered transition will lead to an appearance of a new view controller in a stack. If NO, this is a back transition.

Storyboard

You can specify all transitions in storyboard, as well.

Values are storyboard IDs of view controllers. And keys are determined in CNViewController_Storyboard.h. (Also you can set them in code.)

This approach allows users to move forward by dragging, but all the controllers must be created in the same storyboard.

Segues

If you use a storyboard, you can easily create a segue between two CNViewController-s. When you drop a connection on a destination view controller, you'll see a popup with a list of available segues. bottom (CNBottomSegue), left (CNLeftSegue), right (CNRightSegue), and top (CNLeftSegue) come from CrossNavigation library, but all others are available too. You won't get a crash if you made a common modal transition from CNViewController. But you will, if you made one of those four transitions (bottom, left, right, or top) between view controllers which are not actually objects of CNViewController class (or of it's subclasses), it's required for both controllers.

Restrictions

  • The only one class that should be used directly is CNViewController.
  • The view controllers must be initialized with a xib-file or by a storyboard object.

Demo

Integration

All you need is CrossNavigation directory. Just copy it to your project and import "CNViewController.h" or "CNViewController_Storyboard.h" (if you're going to use storyboard part of the functionality, as well), nothing else.

Podfile

platform :ios, '7.0'
pod "CrossNavigation"

Requirements

  • iOS 7.0+
  • UIKit framework
  • Foundation framework

TODO

  • Support partial screen transitions (like a side screen)
  • Port the library to Swift
  • Segues support

P.S.

I'm really interested to know, what do you think about this library. If you have a complaint, a suggestion, or a question, please, send it on my e-mail: [email protected]. Thank you.

crossnavigation's People

Contributors

artemstepanenko avatar

Watchers

James Cloos avatar Ram Vadranam 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.