你要做的是……
首先在 viewdidload 方法中实现通知,如下所示...
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(rotate:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
现在实现如下所示的旋转方法..
#pragma mark - Rotate Screen Method
- (void)rotate:(NSNotification *)n {
// if (!isFullScreen)
// return;
switch ([[UIDevice currentDevice] orientation]) {
case UIDeviceOrientationLandscapeLeft:
playerView.transform = CGAffineTransformMakeRotation(M_PI / 2);//playerview is view in which you have added MPMoviePlayerViewController object
playerView.frame = CGRectMake(0, 0, 768, 1024);
break;
case UIDeviceOrientationLandscapeRight:
playerView.transform = CGAffineTransformMakeRotation(-M_PI / 2);
playerView.frame = CGRectMake(0, 0,768, 1024);
break;
case UIDeviceOrientationPortrait:
playerView.transform = CGAffineTransformIdentity;
playerView.frame = CGRectMake(0, 0, 768, 1024);
break;
case UIDeviceOrientationPortraitUpsideDown:
playerView.transform = CGAffineTransformMakeRotation(M_PI);
playerView.frame = CGRectMake(0, 0, 768, 1024);
break;
default:
break;
}
}
让我知道它是否有效!
快乐编码!!!