objective-c - 如何旋轉(zhuǎn)嵌入U(xiǎn)IWebView的視頻(iOS 7)?
問(wèn)題描述
我在開(kāi)發(fā)的APP是面向肖像的,但是當(dāng)運(yùn)行視頻(內(nèi)嵌在webview)的時(shí)候,我需要在風(fēng)景模式下重新定位視頻。應(yīng)該怎么解決這一問(wèn)題呢?我找到了一種解決方案,似乎可以解決問(wèn)題。我覺(jué)得這是因?yàn)閕OS 7的更新,但是我不確定。所以,這是我先前使用的,但是現(xiàn)在不起作用了,因?yàn)榇翱诤皖?lèi)名總是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;}
原問(wèn)題:How to rotate a video embed in UIWebView (for iOS 7 only)?
問(wèn)題解答
回答1:答案:Denisia我自己找到了解決方法!在AppDelegate中執(zhí)行如下方法,成功了!我的問(wèn)題是,開(kāi)始的時(shí)候,我沒(méi)有檢查右視圖控制器(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. boot2docker無(wú)法啟動(dòng)2. docker-compose中volumes的問(wèn)題3. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””4. java - SSH框架中寫(xiě)分頁(yè)時(shí)service層中不能注入分頁(yè)類(lèi)5. nignx - docker內(nèi)nginx 80端口被占用6. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.7. javascript - mock.js可以存儲(chǔ)數(shù)據(jù)嗎8. docker api 開(kāi)發(fā)的端口怎么獲取?9. docker images顯示的鏡像過(guò)多,狗眼被亮瞎了,怎么辦?10. golang - 用IDE看docker源碼時(shí)的小問(wèn)題

網(wǎng)公網(wǎng)安備