Reputation: 11
I created an UIWebView inside an UIViewController. This web view contains a youtube video page like this one: http://www.youtube.com/watch?v=oL1RE8JXaIw
When I click on the video link, the iOS video player is launched. Everything is going well till here.
The problem is that when I rotate my application (in landscape mode) and I click on the done button, my View Controller is in landscape mode.
So I've added this callback in the view controller:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return NO;
}
but nothing has changed.
Any idea?
Upvotes: 1
Views: 818
Reputation: 2585
I handled that problem using NSNotification like this in viewDidLoad method
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerDidExitFullScreen)
name:@"UIMoviePlayerControllerDidExitFullscreenNotification"
object:nil];
and this method will call when video ends and you can do necessary changes
- (void)moviePlayerDidExitFullScreen
{
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight || orientation == UIInterfaceOrientationPortraitUpsideDown)
{
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
}
}
Hope that Helps
Upvotes: 0
Reputation: 7921
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return UIInterfaceOrientationPortrait;
}
Upvotes: 0
Reputation: 29975
That orientation code is invalid - make sure to always return YES
for at least one orientation.
Upvotes: 1