Coder Social home page Coder Social logo

nickolashu / jtrevealsidebardemo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jamztang/jtrevealsidebardemo

1.0 2.0 0.0 1.39 MB

A carefully implemented iOS objective-c library to mimic the sidebar layout of the new Facebook app and Path 2.0 app.

License: MIT License

jtrevealsidebardemo's Introduction

JTRevealSidebarV2

An iOS objective-c library template for mimic the sidebar layout of the new Facebook app and the Path app.
JTRevealSidebarV2 is aimed to be a truly flexible and reusable solution for this which has been carefully implemented.

It has been developed under iOS 4.3 and 5.0 devices, sample code has been built using ARC, but the library itself should be both ARC and non-ARC compatible.

Demo

Initialized Left Revealed Left Selected Right Revealed New Pushed New Right Revealed

Abstract

In JTRevealSidebarV2, all sidebars should be considered as navigation items, each sidebar is expected to be able to configure directly through the current view controller.
It is designed to be used with UINavigationController, but technically it should work on other subclasses of UIViewControllers.

How To Use It

Installation

Include all files in JTRevealSidebarV2/.h and JTRevealSidebarV2/.m into your project.

Setting up your first sidebar, configure your viewController and conform to the JTRevealSidebarV2Delegate

@interface ViewController () <JTRevealSidebarV2Delegate>
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.navigationItem.revealSidebarDelegate = self;
}
/*
:
:
*/
#pragma mark JTRevealSidebarDelegate

// This is an examle to configure your sidebar view through a custom UIViewController
- (UIView *)viewForLeftSidebar {
    CGRect mainFrame = [[UIScreen mainScreen] applicationFrame];
    UITableViewController *controller = self.leftSidebarViewController;
    if ( ! controller) {
        self.leftSidebarViewController = [[SidebarViewController alloc] init];
        self.leftSidebarViewController.sidebarDelegate = self;
        controller = self.leftSidebarViewController;
        controller.view.frame = CGRectMake(0, mainFrame.origin.y, 270, mainFrame.size.height);
        controller.title = @"LeftSidebarViewController";
    }
    return controller.view;
}

// This is an examle to configure your sidebar view without a UIViewController
- (UIView *)viewForRightSidebar {
    CGRect mainFrame = [[UIScreen mainScreen] applicationFrame];
    UITableView *view = self.rightSidebarView;
    if ( ! view) {
        view = self.rightSidebarView = [[UITableView alloc] initWithFrame:CGRectMake(50, mainFrame.origin.y, 270, mainFrame.size.height)];
        view.dataSource = self;
        view.delegate   = self;
    }
    return view;
}
@end

Interacting and revealing your sidebar

@implementation ViewController
/*
:
:
*/
#pragma mark Action

- (void)revealLeftSidebar:(id)sender {
    JTRevealedState state = JTRevealedStateLeft;
    if (self.navigationController.revealedState == JTRevealedStateLeft) {
        state = JTRevealedStateNo;
    }
    [self.navigationController setRevealedState:state];
}

- (void)revealRightSidebar:(id)sender {
    JTRevealedState state = JTRevealedStateRight;
    if (self.navigationController.revealedState == JTRevealedStateRight) {
        state = JTRevealedStateNo;
    }
    [self.navigationController setRevealedState:state];
}

@end

Known Issues

Orientation changing is not an officially completed feature, the main thing to fix is the rotation animation and the necessarity of the container created in AppDelegate. Please let me know if you've got any elegant solution and send me a pull request!
Go to JTRevealSidebarV2/ViewController.h and change EXPERIEMENTAL_ORIENTATION_SUPPORT to 1 for testing purpose.

Reminder

Remember to check out the sample working code in JTRevealSidebarDemoV2/ViewController.m, feel free to provide feedback and pull requests. Thanks!

James

jtrevealsidebardemo's People

Contributors

jamztang avatar

Stargazers

 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.