Coder Social home page Coder Social logo

paperfoldmenucontroller's Introduction

PaperFoldMenuController

PaperFoldMenuController is a UITabBarController replacement, but displays the view controllers in a table view on the left side of the screen. This table view is shown/hidden using PaperFold-for-iOS. Selecting from the menu on the left changes the view controller on the right. PaperFoldMenuController uses view controller containment.

Usage

#PaperFoldMenuController

##initWithMenuWidth:numberOfFolds Initialize PaperFoldMenuController

- (id)initWithMenuWidth:(float)menuWidth numberOfFolds:(int)numberOfFolds

####Parameters #####menuWidth This value specifies the width of the table view in the left menu #####numberOfFolds This value specifies the number of folds in the menu table view

##setViewControllers: Sets the root view controllers. Title for each view controllers appears in the menu table view

- (void)setViewControllers:(NSMutableArray *)viewControllers

####Parameters #####viewControllers The array of custom view controllers to display on screen. The title of each view controllers are shown in the menu table view on the left.

##setSelectedIndex: Sets the current root view controller in contentView by index

- (void)setSelectedIndex:(NSUInteger)selectedIndex

####Parameters #####selectedIndex An integer value which is the index of the root view controller in the viewControllers array.

##showMenu:animated: Show or hide the menu table view.

- (void)showMenu:(BOOL)show animated:(BOOL)animated

####Parameters #####show A boolean value to indicate if the menu should be shown or hidden #####animated A boolean value to indicate if the folding/unfolding should be animated #####Discussion This method is automatically called with show=YES and animated=YES when a cell in menu table view is selected.

#PaperFoldMenuControllerDelegate

##paperFoldMenuController:shouldSelectViewController: Ask the delegate whether the specified view controller should be made active

- (BOOL)paperFoldMenuController:(PaperFoldMenuController *)paperFoldMenuController shouldSelectViewController:(UIViewController *)viewController

####Parameters #####paperFoldMenuController The paperfold menu controller containing the viewController. #####viewController The view controller selected in the menu #####Discussion The paperfold menu controller calls this method in response to the user tapping on the left menu. You can use this method to dynamically decide whether the view controller should be made active.

##paperFoldMenuController:didSelectViewController: The paperfold menu controller calls this method in response to the user tapping the left menu, after the viewController is made active.

- (void)paperFoldMenuController:(PaperFoldMenuController *)paperFoldMenuController didSelectViewController:(UIViewController *)viewController

####Parameters #####paperFoldMenuController The paperfold menu controller containing the viewController. #####viewController The view controller selected in the menu

##paperFoldMenuController:shouldFoldMenuToRevealViewController: Ask the delegate if the menu table view should be folded to reveal the selected view controller

- (BOOL)paperFoldMenuController:(PaperFoldMenuController *)paperFoldMenuController shouldFoldMenuToRevealViewController:(UIViewController *)viewController;

####Parameters #####paperFoldMenuController The paperfold menu controller containing the viewController. #####viewController The view controller selected in the menu

Requirements

This project uses ARC. If you are not using ARC in your project, add '-fobjc-arc' as a compiler flag for all the files in this project.

XCode 4.4 is required for auto-synthesis.

iOS 5.0 and above is required because the project uses view controller containment.

Contact

twitter.com/honcheng honcheng.com

paperfoldmenucontroller's People

Contributors

honcheng avatar lxcid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paperfoldmenucontroller's Issues

Changing speed of showMenu:animated

What should I do to change the speed of animation ? Some general direction of what code I should modify would be useful ! I'll post a pull request if you want

use DemoRootViewController as rootViewController (minor issue)

in the didFinishLaunchingWithOptions method, should replace the DemoMenuController as DemoRootViewController in below codes:

for (int i=0; i<8; i++)
{
    DemoMenuController *rootViewController = [[DemoMenuController alloc] init];
    [rootViewController setTitle:[NSString stringWithFormat:@"Root VC %i", i+1]];
    UINavigationController *rootNavController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
    [viewControllers addObject:rootNavController];
}

showMenu

Sometimes the menu fails to open and closes when using the method
- (void)showMenu:(BOOL)show animated:(BOOL)animated

Anyone knows how to solve that?

More than 5 ViewControllers crash

On iPhone i noticed a systematic crash when there are more than 5 menu entries, when selecting menu index >= 4.

Bad Access in:
theNewViewController.view.frame = self.contentView.bounds;

UPDATE_
turns out i had a memory leak somewhere else, sorry

Forever loop in unfoldLeftView

Actually this is an issue of PaperFold, but I can reproduce it easily with this PaperFoldMenuController demo.

Issue reproduce percentage: 100%

Issue reproduce steps using the demo project:

  1. add one left navigation bar button ("Show Menu") for the center view controller

1.1 update two methods below in PaperFoldMenuController.m

  • (void)setViewControllers:(NSMutableArray *)viewControllers
    {
    self.selectedIndex = NSNotFound; // Forces any child view controller to be removed.
    _viewControllers = viewControllers;
    if ([_viewControllers count]>0) [self setSelectedIndex:0];
    [self reloadMenu];

    // add top left button
    for (UIViewController *controller in _viewControllers) {
    [self addLeftButtonForViewController:controller];
    }
    }

  • (void)addViewController:(UIViewController*)viewController;
    {
    if (!_viewControllers) _viewControllers = [NSMutableArray array];
    [self.viewControllers addObject:viewController];
    [self reloadMenu];

    // add top left button
    [self addLeftButtonForViewController:viewController];
    }

1.2 add below methods in PaperFoldMenuController.m

pragma mark

pragma mark - Bar Button Action

///////////////////////////////////////////////////////////////////////////////////////////////////

  • (void)addLeftButtonForViewController:(UIViewController *)controller {
    UIViewController *rootViewController = controller;
    if ([rootViewController isKindOfClass:[UINavigationController class]]) {
    UINavigationController *nav = (UINavigationController *)rootViewController;
    //nav.navigationBar.tintColor = [UIColor colorWithHex:0xf1a0f8];
    if ([nav.viewControllers count] > 0) {
    rootViewController = [nav.viewControllers objectAtIndex:0];
    }
    }
    if (!rootViewController.navigationItem.leftBarButtonItem) {
    rootViewController.navigationItem.leftBarButtonItem = [self leftButtonForCenterPanel];
    }
    }
  • (UIBarButtonItem *)leftButtonForCenterPanel {
    return [[UIBarButtonItem alloc] initWithTitle:@"Show Menu" style:UIBarButtonItemStyleBordered target:self action:@selector(toggleLeftFoldPanel:)];
    }
  • (void)toggleLeftFoldPanel:(id)sender {
    NSLog(@"%s", PRETTY_FUNCTION);
    [self showMenu:YES animated:YES];
    }

after this, you can use the "Show menu" button to show the left menu, but you can't use it to hide the left menu with above code.

  1. in IOS6, we will use pull down gesture to display (pull down from the status bar) the system notification center, right? but if user does not execute this gesture correctly, it will leak to an issue:

2.1 put one finger in the Navigation bar of center view controller
2.2 pull down you finger but DO NOT exceed the bounds of the navigation bar (i.e. limit you pull down gesture in the navigation bar)
2.3 press the "Show Menu" bar button, which will invoke "[self showMenu:YES animated:YES];" method, but it won't work any more, and it will loop in the PaperFoldView::unfoldLeftView method forever....

I guess this happens because you capture the pull down gesture in somewhere, maybe this happens after you merged the code of PaperFold top and bottom fold feature (not sure if this feature has been merged to the main branch of PaperFold), and it break the codes.

Please msg me if you have any question about the issue reproduction.

Thanks in advanced.

No setEnableHorizontalEdgeDragging method on PaperFoldView

As title.

So this method in PaperFoldMenuController is failed:

- (void)setOnlyAllowEdgeDrag:(BOOL)onlyAllowEdgeDrag
{
    [self.paperFoldView setEnableHorizontalEdgeDragging:onlyAllowEdgeDrag];
}

Please advice. I have to comment the body to make the project works.

showMenu:animated doesn't work with presentViewController:animated:completion:

I created a PaperFoldMenuController and setted some viewControllers to it, let's say viewControllerOne and viewControllerTwo. Everything loads perfectly up till this point and if the showMenu:animated is called, it shows the menu without glitches, but when viewControllerOne present a third view controller, say viewControllerThree, using the presentViewController:animated:completion: method, showMenu:animated stops to work.

According to Apple docs, presentViewController:animated:completion: on the iPhone goes full screen, but why can't the PaperFoldMenuController slide itself into the left?

Custom UITableViewCell

Hi, im trying to use a custom UITableViewCell, when i try to set a UILabel text nothing appears, the label is blank but if i use the NSLog the label.text is showing the correct title, so i know the label is getting assigned the text value. Any ideas what I'm doing wrong?

heres the code for the MenuView:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
 NSString *CellIdentifier = @"Cell";
 MenuCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
 if (cell == nil) {
     cell = [[MenuCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
 }



NSMutableDictionary *menuItem = [menuArray objectAtIndex:indexPath.row];
NSString *title = [menuItem objectForKey: @"Title"];

if (indexPath.row % 2) {

    cell.contentView.backgroundColor = [UIColor whiteColor];

}

else{

    cell.contentView.backgroundColor = [UIColor darkGrayColor];
    cell.menuTitleLabel.textColor = [UIColor whiteColor];
}


cell.menuTitleLabel.text = title;
NSLog(@"MenuTitleLabel = %@", cell.menuTitleLabel.text);


return cell;
}

Sometime startup with nothing but blank screen

My codes runs fine with the initial version of PaperFoldMenuController, but after replaced with the latest version, sometime it startup with nothing but blank screen.

When I try to pause this app in Xcode debug window, it show that the callstack:

semaphore_wait_trap
NSOperation start
PaperFoldMenuController viewDidLoad

I guess this is because the viewDidLoadBlockOperation, which is newly introduced.

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.