UiWebView中的视频旋转到风景
问题描述:
我正在尝试使我的UIWebView中的YouTube视频进入横向,但我的应用程序只设置为纵向,而我不希望任何其他景观。我已经尝试了很多东西,例如支持横向和所有其他视图返回不景观,但它不工作。我的项目是基于标签的应用程序。如果我必须整个视图可以旋转,而不仅仅是视频,但如果YouTube视频一旦进入全屏(自动发生)就可以旋转,这将是非常棒的。UiWebView中的视频旋转到风景
答
您可以让您的控制器订阅UIDeviceOrientationDidChangeNotification
通知,处理通知的方法只旋转包含视频的UIWebView
。
这将是这样的:
[[NSNotificationCenter defaultCenter] addObserver:self
selector: @selector(handleOrientationChangeNotification:)
name: UIDeviceOrientationDidChangeNotification object:nil];
-(void)handleOrientationChangeNotification:(NSNotification *)notification
{
UIDeviceOrientation currentDeviceOrientation = [[UIDevice currentDevice] orientation];
if (currentDeviceOrientation == UIDeviceOrientationLandscapeRight) {
webView.transform = CGAffineTransformRotateMake(M_PI_2);
webView.bounds = (CGRect){480,320};
webView.center = (CGPoint){240,160};
} else if (...
...
}
感谢,但我想我可能已经是试过了,不只是让Web视图旋转和视频全屏一次去的画像? – rblue36 2013-02-10 22:21:13
我不想旋转webview我需要在webview中旋转html5视频.is有任何可能性。 – 2013-04-04 09:07:39