objective-c - 如何旋转嵌入UIWebView的视频(iOS 7)?
问题描述
我在开发的APP是面向肖像的,但是当运行视频(内嵌在webview)的时候,我需要在风景模式下重新定位视频。应该怎么解决这一问题呢?我找到了一种解决方案,似乎可以解决问题。我觉得这是因为iOS 7的更新,但是我不确定。所以,这是我先前使用的,但是现在不起作用了,因为窗口和类名总是nil。
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{id presentedViewController = [window.rootViewController presentedViewController];NSString *className = presentedViewController ? NSStringFromClass([presentedViewController class]) : nil;if (window && [className isEqualToString:@'MPInlineVideoFullscreenViewController']) { return UIInterfaceOrientationMaskAll;} else { return UIInterfaceOrientationMaskPortrait;}
原问题:How to rotate a video embed in UIWebView (for iOS 7 only)?
问题解答
回答1:答案:Denisia我自己找到了解决方法!在AppDelegate中执行如下方法,成功了!我的问题是,开始的时候,我没有检查右视图控制器(view controller)。
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {NSString *className = NSStringFromClass([window class]);if ([((UINavigationController *)window.rootViewController) respondsToSelector:@selector(visibleViewController)]) { className = NSStringFromClass([((UINavigationController *)window.rootViewController).visibleViewController class]);}if ([className isEqualToString:@'MPFullscreenWindow'] || [className isEqualToString:@'MPInlineVideoFullscreenViewController']) { return UIInterfaceOrientationMaskAll;} else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){ return UIInterfaceOrientationMaskLandscape;} else { return UIInterfaceOrientationMaskPortrait;}
Immi试试这个:
-(BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation{return YES;}
如果你想在屏幕不显示视频的时候,不让UIViewController旋转,就使用下面的:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{if(webView && webView.superView) return YES;return UIInterfaceOrientationIsPortrait(interfaceOrientation);}
相关文章:
1. html5 - iframe src可以引入其他域名或者IP吧iframe src可以是其他域名过IP吧2. javascript - 给js写的盒子添加css样式,css样式没起作用。3. javascript - 如何将psd裁切下来的图片非常清晰的宣示出来4. javascript - vuex中action应该怎么分发事件5. html5 - 请问一下写H5的时候 你们都是兼容那些手机6. html5 - ElementUI table中el-table-column怎么设置百分比显示。7. mysqli函数8. web前端页面中实现表格效果,这个表格是可编辑的9. javascript - h5页面中iframe无法唤起iOS应用?10. 数据挖掘 - 如何用python实现《多社交网络的影响力最大化问题分析》中的算法?
![php-_server-php_self - nginx $_SERVER[’PHP_SELF’] 得到重复路径是什么原因?](http://www.haobala.com/attached/image/news/202309/1123091c0c.png)
网公网安备