ios - Slide Menu Programmatically -
ios - Slide Menu Programmatically -
i have class called "home" , class called "menu" tableview, in home create button force menu, when click on button create frame move , appear menu can't click on table view cell of menu, priority home. how can alter , create work?
- (void)viewdidload { [super viewdidload]; menuviewcontroller = [[itmenuviewcontroller alloc] init]; menuviewcontroller.view.frame = cgrectmake(0, 0, 0, 568); [self.view addsubview:menuviewcontroller.view]; btn = [[uibutton alloc] init]; btn = [uibutton buttonwithtype:uibuttontyperoundedrect]; [btn addtarget:self action:@selector(pushmenu) forcontrolevents:uicontroleventtouchupinside]; [btn settitle:@"push" forstate:uicontrolstatenormal]; btn.frame = cgrectmake(40, 300, 240, 40); [btn setbackgroundcolor:[uicolor orangecolor]]; [btn settitlecolor:[uicolor whitecolor] forstate:uicontrolstatenormal]; btn.layer.cornerradius = 2; btn.tag = 1; btn.clipstobounds = yes; //set other button properties here. [self.view addsubview:btn]; } - (void)pushmenu { if (menuviewcontroller.view.frame.origin.x < 0 && btn.tag == 2) { [uiview animatekeyframeswithduration:0.5 delay:0 options:uiviewanimationoptioncurveeasein animations:^{ self.view.frame = cgrectmake(0, 0, 320, 568); menuviewcontroller.view.frame=cgrectmake(0, 0, 0, 568); } completion:^(bool finished) { btn.tag = 1; }]; } if (menuviewcontroller.view.frame.origin.x >= 0 && btn.tag == 1) { [uiview animatekeyframeswithduration:0.5 delay:0 options:uiviewanimationoptioncurveeaseout animations:^{ self.view.frame = cgrectmake(200, 0, 320, 568); menuviewcontroller.view.frame=cgrectmake(-self.view.frame.size.width + 0, 0, self.view.frame.size.width, 568); [self.view.layer setcornerradius:4]; [self.view.layer setshadowcolor:[uicolor blackcolor].cgcolor]; [self.view.layer setshadowopacity:0.8]; [self.view.layer setshadowoffset:cgsizemake(0.0f, 2.5f)]; } completion:^(bool finished) { btn.tag = 2; }]; }} }
check pprevealsideviewcontroller. help want https://github.com/ipup/pprevealsideviewcontroller.
you can add together home view controller in appdelegate this:
homeviewcontroller *home = [[homeviewcontroller alloc initwithnibname:@"mainviewcontroller" bundle:nil]; uinavigationcontroller *nav = [[uinavigationcontroller alloc] initwithrootviewcontroller:home]; _revealsideviewcontroller = [[pprevealsideviewcontroller alloc] initwithrootviewcontroller:nav]; self.window.rootviewcontroller = _revealsideviewcontroller;
and force manu viewcontroller this:
menuviewcontroller *menu = [[menuviewcontroller alloc] initwithnibname:@"menuviewcontroller" bundle:nil ]; [self.revealsideviewcontroller pushviewcontroller:menu ondirection:pprevealsidedirectionbottom animated:yes];
edit
to add together pprevealsideviewcontroller submodule project go terminal:
$ cd /path/to/myapplication # if new project, initialize git... $ git init $ git submodule add together git://github.com/ipup/pprevealsideviewcontroller.git vendor/pprevealsideviewcontroller $ git submodule update --init --recursive
-in xcode project, take pprevealsideviewcontroller.h , .m pprevealsideviewcontroller folder , drag them project.
-import pprevealsideviewcontroller.h file pch file or appdelegate file.
-add quartzcore framework.
-start using new controller!
ios objective-c xcode
Comments
Post a Comment