ios - Override Double Tap to Zoom in MKMapView -
is possible replace gesture in ios 6 custom gesture? have gesture show map in full screen hiding status , navigation bars , works zooms every time done.
here how have gesture implemented.
- (bool)gesturerecognizer:(uigesturerecognizer *)gesturerecognizer shouldrecognizesimultaneouslywithgesturerecognizer:(uigesturerecognizer *)othergesturerecognizer { return yes; }
in viewdidload:
uitapgesturerecognizer *tap = [[uitapgesturerecognizer alloc]initwithtarget:self action:@selector(togglebars:)]; tap.numberoftapsrequired = 2; [self.view addgesturerecognizer:tap]; tap.delegate = self;
gesture method:
- (void)togglebars:(uitapgesturerecognizer *)gesture { bool barshidden = self.navigationcontroller.navigationbar.hidden; if (!barshidden) { [[uiapplication sharedapplication] setstatusbarhidden:yes withanimation:uistatusbaranimationslide]; [self hidetabbar:self.tabbarcontroller]; } else if (barshidden) { [[uiapplication sharedapplication] setstatusbarhidden:no withanimation:uistatusbaranimationslide]; [self showtabbar:self.tabbarcontroller]; } [self.navigationcontroller setnavigationbarhidden:!barshidden animated:yes]; }
methods hiding/showing tab bar:
- (void) hidetabbar:(uitabbarcontroller *) tabbarcontroller { cgrect screenrect = [[uiscreen mainscreen] bounds]; [uiview beginanimations:nil context:null]; [uiview setanimationduration:0.5]; float fheight = screenrect.size.height; if( uideviceorientationislandscape([uiapplication sharedapplication].statusbarorientation) ) { fheight = screenrect.size.width; } for(uiview *view in tabbarcontroller.view.subviews) { if([view iskindofclass:[uitabbar class]]) { [view setframe:cgrectmake(view.frame.origin.x, fheight, view.frame.size.width, view.frame.size.height)]; } else { [view setframe:cgrectmake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fheight)]; view.backgroundcolor = [uicolor blackcolor]; } } [uiview commitanimations]; } - (void) showtabbar:(uitabbarcontroller *) tabbarcontroller { cgrect screenrect = [[uiscreen mainscreen] bounds]; float fheight = screenrect.size.height - 49.0; if( uideviceorientationislandscape([uiapplication sharedapplication].statusbarorientation) ) { fheight = screenrect.size.width - 49.0; } [uiview beginanimations:nil context:null]; [uiview setanimationduration:0.5]; for(uiview *view in tabbarcontroller.view.subviews) { if([view iskindofclass:[uitabbar class]]) { [view setframe:cgrectmake(view.frame.origin.x, fheight, view.frame.size.width, view.frame.size.height)]; } else { [view setframe:cgrectmake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fheight)]; } } [uiview commitanimations]; }
Comments
Post a Comment