0

我想做的很简单。

我有一个UIViewController(仅限纵向!)并且在它的视图内我想显示一个视频(在视图的一部分中)。然后我想添加一个UIButton使用户能够全屏显示视频。当视频全屏时,我希望视频跟随设备的方向,而不是UIViewController呈现视频,这样如果用户处于横向并退出全屏模式,则UIViewController应该是纵向的!我还想在视频全屏时添加自定义控件。

你知道我应该怎么做吗?

谢谢

4

1 回答 1

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;
}
于 2013-01-09T02:14:50.280 回答