4

I'm embedding a Youtube video in a browser which is part of an all portrait application. When you launch the youtube video, it plays in MPAVController and rotation in Landscape is permitted. This is not an issue for me, but the problem is if the video is in landscape and i press "OK" to dismiss the video; i return to the browser but the iPhone status bar is now stuck in landscape mode leaving a blank space on the top of the app, as well as the status bar overlappting the right or left part of my app depending on rotation orientation.

My view controller containing the UIWebView is locked in portrait:

- (BOOL) shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}

Note that this issue is not present when compiling with an SDK prior to 6.0.

Anyone with a similar problem has a solution?

Hulk_SMASH
  • 553
  • 1
  • 7
  • 13
  • It almost certainly won't affect your problem (ie, this probably isn't an answer) but don't you want `shouldAutorotate` to be `NO`? – Tommy Oct 09 '12 at 19:39
  • 5
    can you tell me how do you support Landscape for MPAVController in a All-portrait app? – user739711 Nov 12 '12 at 11:00
  • @user739711, this should answer your question (the title is about `MPMovieViewController`, but this will also work for `MPAVController`): http://stackoverflow.com/questions/13021520/how-to-play-landscape-video-with-mpmovieviewcontroller-in-a-portrait-only-app – JRG-Developer Jan 11 '13 at 00:31

2 Answers2

5

I am facing the same problem. Here is how I have solved it:

First register to receive ExitFullscreenNotification, on the ViewController that holds the UIWebView:

- (void)viewDidLoad {
    [super viewDidLoad];
    // For FullSCreen Exit
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(youTubeVideoExit:) 
                                                 name:@"UIMoviePlayerControllerDidExitFullscreenNotification"
                                               object:nil];
}

Then, on the "exit fullscreen" handler, force Portrait mode:

- (void)youTubeVideoExit:(id)sender {
  [[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];
}

When the video finishes in landscape mode, the user sees the status bar changing its location for a split second. This may not be the best solution, but at least solves the problem.

Hope it helps!

alex
  • 300
  • 2
  • 11
0

It turns out my view was embedded in a UINavigationController so i needed to handle my rotation over there.

I created a category and put my rotation code in there

UINavigationController+Autorotate.m

#import "UINavigationController+Autorotate.h"

@implementation UINavigationController (Autorotate)

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

@end

UINavigationController+Autorotate.h

#import <UIKit/UIKit.h>

@interface UINavigationController (Autorotate)

- (NSUInteger)supportedInterfaceOrientations;

@end
Hulk_SMASH
  • 553
  • 1
  • 7
  • 13
  • It's a really bad practice to override methods with a Category. Be careful if your going to do something like this. – atreat Feb 18 '13 at 17:50