Orientation issue after Video dismissed: Cordova 2.1.0 + iOS 6
-
07-07-2021 - |
Pregunta
I'm building a Phonegap app that needs to play fullscreen html5 videos.
My problem is that with Phonegap 2.1.0 and iOS 6 something changed with orientation, and everytime I dismiss a fullscreen video (press the done button), the video forces my app in portrait mode even though the App is locked in landscape mode.
I am not doing any obj-c magic here, it's a standard html5 video tag.
<video id="myvideo" src="goat.mp4" controls="" autobuffer=""></video>
I assume it's the video layer on top of my viewController that forces the orientation change, but how do I make it stop?
Any ideas would be greatly appreciated! Thanks in advance...
Solución
For PhoneGap 2.1, check out the bug fix
In "MainViewController.m" change viewWillAppear
to
- (void)viewWillAppear:(BOOL)animated
{
// Set the main view to utilize the entire application frame space of the device.
// Change this to suit your view's UI footprint needs in your application.
UIView* rootView =[[[[UIApplication sharedApplication] keyWindow] rootViewController] view];
CGRect webViewFrame = [[[rootView subviews] objectAtIndex:0] frame]; // first subview is the UIWebView
if (CGRectEqualToRect(webViewFrame, CGRectZero)) { // UIWebView is sized according to its parent, here it hasn't been sized yet
self.view.frame = [[UIScreen mainScreen] applicationFrame]; // size UIWebView's parent according to application frame, which will in turn resize the UIWebView
}
[super viewWillAppear:animated];
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow