6

I came across an issue in my current project, so I spun up a simple app to see if I could isolate the problem. In my app delegate I hide the status bar.

[application setStatusBarHidden:YES animated:NO];

In my single view controller I have this code:

- (void)loadVideo
{
    // HTML to embed YouTube video
    NSString *youTubeVideoHTML = @"<html><head>\
    <body style=\"margin:0\">\
    <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
    width=\"%0.0f\" height=\"%0.0f\"></embed>\
    </body></html>";

    // Populate HTML with the URL and requested frame size
    NSString *html = [NSString stringWithFormat:youTubeVideoHTML, @"http://www.youtube.com/watch?v=VDRoBnL1gRg", 500, 500];

    // Load the html into the webview
    [self.webview loadHTMLString:html baseURL:nil];
}

The app is also set to autorotate.

Now, here's the problem: When I play the youtube video, enter fullscreen mode, rotate the device 90 degrees, and hit "Done" to exit fullscreen, the entire interface remains shifted down 20px as if it were accommodating a status bar. I noticed that when viewing a video in full screen, ios adds a status bar, so I'm guessing that's part of the issue. I've seen the problem occur with the native video player as well.

Any ideas?

Michael
  • 373
  • 2
  • 15

4 Answers4

3

I used this YouTube embed method recently for my app Game Guide: Black Ops 2, and I was having this problem along with being shown the rootViewController when hitting the movie player's "done" button. Checking "Wants Full Screen" on the rootViewController fixed the 20 pixel shift, and to fix the rootViewController being displayed after pushing the "done" button I added this to the rootViewController which was adding a UIViewController (with tableView) as a child which was using [presentViewControllerAnimated:(BOOL) completion:nil] to show the ViewController with the YouTube Video Embed.

Now everything is working perfectly... check out the Videos tab in my app if you want to see how it behaves.

-(void)viewDidAppear:(BOOL)animated {
    NSLog(@"Main View viewDidAppear...");
    [super viewDidAppear:animated];
    [self dismissViewControllerAnimated:YES completion:nil];

}

1

I had a similar problem.

I created views in storyboard. Checking Wants full Screen in layout section of view controller settings solved it for me.

Charles Menguy
  • 40,830
  • 17
  • 95
  • 117
0

If by any chance you're using a UITabBarController, you must install this view as the root of your window. Unlike other view controllers, a tab bar interface should never be installed as a child of another view controller.

picciano
  • 22,341
  • 9
  • 69
  • 82
  • I'm not using UITabBarController. The dummy app I created contains only a UIViewController containing a UIView containing a UIWebView. Thanks for answering. – Michael Feb 13 '12 at 20:03
0

To try to add to your info.plist next key: UIStatusBarHidden ("Status bar is initially hidden") with value YES.

alexmorhun
  • 1,903
  • 2
  • 18
  • 23
  • Tried it. Same result. Thanks for the suggestion, though. – Michael Feb 13 '12 at 20:07
  • Do you have a xib file for your UIViewController? Check the size of views in the xib file. Most likely, your primary view installed height of 460 px. It should be for all kinds of height 480. – alexmorhun Feb 14 '12 at 09:31