iphone - iOS Hiding Status bar and tab bar in iOS 6 + 7 -
i've got tabbed application , in 1 tab there uiwebview. when rotate device landscape i'd make uiwebview full screen on status bar , tab bar.
//edit
ok, i've got working in ios 6 - when rotating , hiding tab bar leave black space tab bar was, fheight code fixes this. on ios 6 worked perfectly, creates black bar problem ios 6 having!! ideas workaround this?
- (void)willrotatetointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation duration:(nstimeinterval)duration; { if(tointerfaceorientation == uiinterfaceorientationlandscapeleft || tointerfaceorientation == uiinterfaceorientationlandscaperight) { [self hidetabbar:self.tabbarcontroller]; [[uiapplication sharedapplication] setstatusbarhidden:true withanimation:uistatusbaranimationslide]; } else { [self showtabbar:self.tabbarcontroller]; [[uiapplication sharedapplication] setstatusbarhidden:false withanimation:uistatusbaranimationslide]; } } - (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 self.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]; }
//edit 2
i've tried using i'm not sure view need pass in? it's supposed work ios 6 , 7
- (void)settabbarhidden:(bool)hidden view:(uiview *)view animated:(bool)animated { if (self.tabbar.hidden == hidden) return; cgrect screenrect = [[uiscreen mainscreen] bounds]; float height = 0.0f; if(uideviceorientationislandscape([uiapplication sharedapplication].statusbarorientation)) { height = screenrect.size.width; } else { height = screenrect.size.height; } if (!hidden) { height -= cgrectgetheight(self.tabbar.frame); } void (^workerblock)() = ^() { self.tabbar.frame = cgrectmake(cgrectgetminx(self.tabbar.frame), height, cgrectgetwidth(self.tabbar.frame), cgrectgetheight(self.tabbar.frame)); view.frame = cgrectmake(cgrectgetminx(view.frame), cgrectgetminy(view.frame), cgrectgetwidth(view.frame), height); }; void (^completionblock)(bool finished) = ^(bool finished) { self.tabbar.hidden = hidden; }; if (animated) { [uiview animatewithduration:0.25f animations:workerblock completion:completionblock]; } else { workerblock(); completionblock(yes); } }
yes, use appropriate uiviewcontroller
rotation methods. hiding tab bar controller easy enough, status bar more difficult on ios 7. research how , should fine.
Comments
Post a Comment