objective-c - 如何旋轉(zhuǎn)嵌入UIWebView的視頻(iOS 7)?
問題描述
我在開發(fā)的APP是面向肖像的,但是當(dāng)運行視頻(內(nèi)嵌在webview)的時候,我需要在風(fēng)景模式下重新定位視頻。應(yīng)該怎么解決這一問題呢?我找到了一種解決方案,似乎可以解決問題。我覺得這是因為iOS 7的更新,但是我不確定。所以,這是我先前使用的,但是現(xiàn)在不起作用了,因為窗口和類名總是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中執(zhí)行如下方法,成功了!我的問題是,開始的時候,我沒有檢查右視圖控制器(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旋轉(zhuǎn),就使用下面的:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{if(webView && webView.superView) return YES;return UIInterfaceOrientationIsPortrait(interfaceOrientation);}
相關(guān)文章:
1. javascript - 在靜態(tài)頁面上用load 引入的頁面文件問題?2. javascript - webpack打包后的bundlejs文件代碼不知道什么意思.3. android - RxJavar用什么操作符可以使數(shù)據(jù)每隔一段時間取出一個4. Android的webView如何實現(xiàn)網(wǎng)頁 錄音功能?5. java - oracle對漢字字段按照拼音排序的函數(shù)和sql語句是什么?6. css - 關(guān)于ul的布局7. css - 如何使用 vue transition 實現(xiàn) ios 按鈕一樣的平滑切換效果8. Java游戲服務(wù)器開發(fā)和網(wǎng)站、app服務(wù)端的開發(fā)都差不多的嗎???實現(xiàn)的思路和方法9. javascript - vue組件通過eventBus通信時,報錯a.$on is not a function10. html - 哪些情況下float會失效?
