Giter VIP home page Giter VIP logo

mrnavigationcontroller's Introduction

MRNavigationController

A UINavigationController subclass with a pushViewController method that accepts push and pop blocks, as well as navigation bar and toolbar visibility settings, for each pushed controller. Here is an example:

#import "MRNavigationController.h"

self.vc1 = [[UIViewController alloc] init];
self.vc2 = [[UIViewController alloc] init];
self.nav = [[MRNavigationController alloc] initWithRootViewController:self.vc1 navigationBarHidden:YES toolbarHidden:YES];
[self.nav pushViewController:self.vc2 animated:YES navigationBarHidden:NO toolbarHidden:NO push:^{
    NSLog(@"VC1 pushed VC2");
}
pop:^{
	NSLog(@"VC2 popped");
	self.vc2 = nil;
}];

In this sample, the navigation controller will display the vc1 view controller with no navigation bar and no toolbar. The first log statement will then be printed. The vc2 view controller will then be animated onto the screen with a navigation bar and toolbar. When its back button is pressed, the second log statement will be printed, the vc2 view controller will be animated away and cleared from memory, and the vc1 view controller will once again appear with no navigation bar and no toolbar.

The pop block is executed whether the back button is pressed or if the view controller is popped manually via one of the standard pop methods:

  • popViewControllerAnimated:
  • popToViewController:animated:
  • popToRootViewControllerAnimated:

The following superclass methods can still be used, but pushed view controllers will be assigned a default of navigationBarHidden:NO and toolbarHidden:YES and no push or pop blocks will be executed:

  • initWithRootViewController:
  • pushViewController:animated:

You can still use your own delegate thanks to a trick from a fantastic library called HTDelegateProxy.

For a live example, download and run the Xcode project.

Installation

I’ve published this library as a CocoaPod, which is the easiest way to install it. Otherwise, simply manually copy these class files and HTDelegateProxy files into your project.

mrnavigationcontroller's People

Contributors

martinrybak avatar

Watchers

 avatar  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.