IOS-PPRevealViewController sidebar

Source: Internet
Author: User

IOS-PPRevealViewController sidebar
> DefinitionPPRevealViewController

PPRevealSideViewControllerDelegate@property (strong, nonatomic) PPRevealSideViewController *revealSideViewController;
> Initialization
HomeViewController * con = [[HomeViewController alloc] init]; UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController: con]; _ metadata = [PPRevealSideViewController alloc] initWithRootViewController: nav]; _ revealSideViewController. delegate = self; _ revealSideViewController. options = PPRevealSideOptionsNone; // shadow of the intermediate interface _ revealSideViewController. bouncingOffset = 0; _ revealSideViewController. panInteractionsWhenClosed = PPRevealSideInteractionNavigationBar | PPRevealSideInteractionContentView; // you can slide the navigation bar and content to display the self. window. rootViewController = _ revealSideViewController;
-(PPRevealSideDirection) pprevealSideViewController :( PPRevealSideViewController *) controller directionsAllowedForPanningOnView :( UIView *) view {return pprevealsidedireleft; // only supports left sliding}
> Use

Add a sidebar to the homepage

In HomeViewController-(void) viewWillAppear :( BOOL) animated {[super viewWillAppear: YES]; SideViewController * side = [[SideViewController alloc] init]; [self. revealSideViewController preloadViewController: side forSide: PPRevealSideDirectionLeft];}

Go to the sidebar

           SideViewController *c = [[SideViewController alloc] initWithNibName:nil bundle:nil];            UINavigationController* nav = [[UINavigationController alloc]initWithRootViewController:c];            [self.revealSideViewController pushViewController:nav onDirection:PPRevealSideDirectionLeft withOffset:70 animated:YES];           PP_RELEASE(c);           PP_RELEASE(nav);

From the sidebar to the previous attempt, self is the sidebar

  [self.revealSideViewController popViewControllerAnimated:YES];

Go to the home page from other pages

HomeViewController *c = [[HomeViewController alloc] initWithNibName:nil bundle:nil];    UINavigationController *n = [[UINavigationController alloc] initWithRootViewController:c];    [self.revealSideViewController popViewControllerWithNewCenterController:n animated:YES];   PP_RELEASE(c);   PP_RELEASE(n);

From other pages to the sidebar

HomeViewController* con = [[HomeViewController alloc]initWithNibName:nil bundle:nil];    UINavigationController* nav =[[UINavigationController alloc]initWithRootViewController:con];    [self.revealSideViewController popViewControllerWithNewCenterController:nav animated:YES completion:^{        SideViewController *c = [[SideViewController alloc] initWithNibName:nil bundle:nil];        UINavigationController* nav = [[UINavigationController alloc]initWithRootViewController:c];       [self.revealSideViewController pushViewController:nav onDirection:PPRevealSideDirectionLeft withOffset:70 animated:YES];        PP_RELEASE(c);        PP_RELEASE(nav);    }];    PP_RELEASE(con);    PP_RELEASE(nav);

Enter a New View

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:ViewController];    [self.revealSideViewController popViewControllerWithNewCenterController:nav animated:YES];    PP_RELEASE(ViewController);    PP_RELEASE(nav);
Postscript

The Sidebar function is available only when sliding within a fixed screen range is required. In the. m method-
(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldReceiveTouch:(UITouch *)touch
Add

     CGPoint poit = [touch locationInView:self.view ];//        NSLog(@"%f,%d",poit.x,_wasClosed);        if (poit.x >100) {\            if (!_wasClosed) {                return YES;            }else{            return NO;            }        }

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.