In my application the default is visible by the status bar. And my app supports portrait orientation as well as landscape. When I want to play video, I am hiding the status bar so that my video can be screened in full screen. . And when the video is complete, I am bringing back the status bar
To show me the video using the following code:
UIWindow * window = [[ UIApplication sharedApplication] KeyWindow]; [Add window subeview: player view]; (I can not use the view controller in my code. This is a restriction)
Problem: My app is now in the scenario, on the click of a button I'll hide the status bar and start playing the video. When the video is playing, I change the orientation of the phone to the portrait and I allow the video to be completed. When the video is complete, the device is still in portrait mode, the player view is removed and the status bar is shown again. Now I have seen that my portrait view is showing up to 20 pixels and that status bar. But when I started the app for the time of FIR, the status bar is shown first and below, my thoughts have been shown.
How should I control this situation?
In the simple use of the following code in a view controller.
- (zero) viewDidoadload {[UIApplication ShareApp] setStatusBarHidden: Yes]; [Self-choice selector: @Selector (Showstatus Again) with object: zero after Della: 6.0]; [Super viewedload]; } - (zero) shostatagain {[UIApplication shared application] set status barhard: no]; } // Override to allow orientation other than default portrait orientation - (BOOL) should be requiredAutrootettoInterfaceApplication: (UINFFSA) Interface Orientation {return yes; } When you run an app with the above code, it will start in the image. Now rotate it in the scenario and you can notice this issue.
I encountered a similar problem, which I encountered with a class on UINavigationController.
UINavigationController + LayoutCorrecting.h:
@interfaceUInavigationController (LayoutCorrecting) - (zero) recalculateNavigationBarFrameRelativeToStatusBar; @end UINavigationController + LayoutCorrecting.m:
code #import ) - (empty) recycled navigation bar frameriletostatsbar {CGRTSBF = [[UIPAPP sharing application] statusbar frame]; If (UIInterfaceOrientationIsLandscape (self.interfaceOrientation)) self.navigationBar.top = sbf.size.width; Other self Navigationbar.pull = sbf.size.height; } @end By declaring this on UIViewController and making sure that this range is slightly tweak by making navigation from navigation bar.top, adjusting it instead of controller.view.frame, I suppose That you will be good to go Just after you finish playing your movie, be sure to call the category method on your visual controller and you have already shown the status bar.
And to stop any confusion, it is necessary to use the width of the status bar in landscape mode because UIWindow's coordinate system always works like it does In the picture, in spite of how you hold the device. This is in contrast to the SubViews (UIView Instances), which is managed by the UIVIUIUIT-Controller, which benefits from automatic coordination changes. PS: Since you have to zoom the frame of your view in the context of the window, this function can also help.
CGRect CGRectOffsetRectForOrientation (CGRect Rect, CGFloat dx, CGFloat DY, UIInterfaceOrientation Orientation) {CGRect newRect = Rect. Switch (Orientation) {case UIInterfaceOrientationPortrait: newRect.origin.x + = dx; NewRect.origin.y + = dy; break; Case UIInterfaceOrientationPortraitUpsideDown: newRect.origin.x - = dx; NewRect.origin.y - = D; break; Case UIInterfaceOrientationLandscapeLeft: newRect.origin.y - = dx; NewRect.origin.x + = dy; break; Case UIInterfaceOrientationLandscapeRight: newRect.origin.y + = dx; NewRect.origin.x - = D; break; Default: Break; } New returns; }
Comments
Post a Comment