objective-c - 如何旋轉(zhuǎn)嵌入U(xiǎn)IWebView的視頻(iOS 7)?
問題描述
我在開發(fā)的APP是面向肖像的,但是當(dāng)運(yùn)行視頻(內(nèi)嵌在webview)的時(shí)候,我需要在風(fēng)景模式下重新定位視頻。應(yīng)該怎么解決這一問題呢?我找到了一種解決方案,似乎可以解決問題。我覺得這是因?yàn)閕OS 7的更新,但是我不確定。所以,這是我先前使用的,但是現(xiàn)在不起作用了,因?yàn)榇翱诤皖惷偸莕il。
- (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í)行如下方法,成功了!我的問題是,開始的時(shí)候,我沒有檢查右視圖控制器(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試試這個(gè):
-(BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation{return YES;}
如果你想在屏幕不顯示視頻的時(shí)候,不讓UIViewController旋轉(zhuǎn),就使用下面的:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{if(webView && webView.superView) return YES;return UIInterfaceOrientationIsPortrait(interfaceOrientation);}
相關(guān)文章:
1. javascript - 微信網(wǎng)頁開發(fā)從菜單進(jìn)入頁面后,按返回鍵沒有關(guān)閉瀏覽器而是刷新當(dāng)前頁面,求解決?2. mysql replace 死鎖3. android - 安卓做前端,PHP做后臺(tái)服務(wù)器 有什么需要注意的?4. mysql - ubuntu開啟3306端口失敗,有什么辦法可以解決?5. 求救一下,用新版的phpstudy,數(shù)據(jù)庫過段時(shí)間會(huì)消失是什么情況?6. extra沒有加載出來7. python3.x - Python not 運(yùn)算符的問題8. python - 數(shù)據(jù)與循環(huán)次數(shù)對(duì)應(yīng)不上9. mysql - C#連接數(shù)據(jù)庫時(shí)一直這一句出問題int i = cmd.ExecuteNonQuery();10. python小白,關(guān)于函數(shù)問題
