2013-01-08 21 views
0

我想要做的事很簡單。如何呈現視頻並僅將其旋轉?

我有一個UIViewController(僅限肖像!),並在其視圖內部顯示視頻(在視圖的一部分中)。然後我想添加一個UIButton,使用戶能夠全屏顯示視頻。 當視頻處於全屏模式時,我希望視頻遵循設備的方向,但不要提供視頻UIViewController,以便在用戶處於橫向模式並退出全屏模式時,UIViewController應爲縱向! 我也想在視頻全屏時添加自定義控件。

你有什麼想法應該如何繼續?

謝謝

回答

0

我曾經這樣做過。只需setTransform:CGAffineTransformMakeRotation(M_PI/2)

- (void)rotateVideoToLandscape { 

    int64_t delayInSeconds = 0.5; 
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); 
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 
     [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight]; 
    }); 

    // Before rotate the video, exchange the width & height for a better user-experience. 
    [self.view setBounds:CGRectMake(0, 0, self.view.height, self.view.width)]; 
    [self.view setCenter:CGPointMake(self.view.width/2, self.view.height/2)]; 
    [self.view setTransform:CGAffineTransformMakeRotation(M_PI/2)]; 

    CGRect playerRect = self.view.bounds; 
    // Do something needed. 
    self.moviePlayerController.view.frame = playerRect; 
} 
+0

感謝您的編輯。 @ IOS的​​開發 –