2013-02-10 44 views
0

我正在嘗試使我的UIWebView中的YouTube視頻進入橫向,但我的應用程序只設置爲縱向,而我不希望任何其他景觀。我已經嘗試了很多東西,例如支持橫向和所有其他視圖返回不景觀,但它不工作。我的項目是基於標籤的應用程序。如果我必須整個視圖可以旋轉,而不僅僅是視頻,但如果YouTube視頻一旦進入全屏(自動發生)就可以旋轉,這將是非常棒的。UiWebView中的視頻旋轉到風景

回答

0

您可以讓您的控制器訂閱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 (... 
     ... 
} 
+0

感謝,但我想我可能已經是試過了,不只是讓Web視圖旋轉和視頻全屏一次去的畫像? – rblue36 2013-02-10 22:21:13

+0

我不想旋轉webview我需要在webview中旋轉html5視頻.is有任何可能性。 – 2013-04-04 09:07:39