开发者

Why is the title bar appearing behind the status bar after a rotation?

I have a UIViewController whose view is a UIWebView with an embedd开发者_C百科ed movie. When the movie is playing full screen, and the device is rotated, the title bar ends up behind the status bar after the movie is dismissed. Why might this happen?

Why is the title bar appearing behind the status bar after a rotation?


Turns out that the animation of the view controller's view wasn't finished when the video started. This caused it to be redisplayed over the video player view.


My solution:

(void)viewDidLoad
{
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:NO];
    [UIApplication sharedApplication].keyWindow.frame=CGRectMake(0, 20, 320, 460);
    self.navigationController.navigationBar.hidden=NO;
 }


did you autoresizingMask on the UIWebView

webView.autoresizingMask=(UIViewAutoresizingFlexibleHeight |
                                      UIViewAutoresizingFlexibleWidth);

and

-(BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) orientation 
{
    return YES;
}


It's no way to resolve this problem using MPMoviePlayerNotification, because UIWebView Video Don't use MPMoviePlayerViewController or it's private for developer. But, there's another way to fix this bug.

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(handleStatusBarFrameDidChange)
                                             name:UIApplicationDidChangeStatusBarFrameNotification
                                           object:nil];

- (void)handleStatusBarFrameDidChange {
    self.navigationController.navigationBarHidden = YES;
    self.navigationController.navigationBarHidden = NO;
}    
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜