```
//.h
@interfaceAppDelegate:UIResponder
@property(strong,nonatomic)UIWindow*window;
@property(nonatomic,assign)BOOLallowRotation;
@end
//.m
- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window{
if (self.allowRotation) {
returnUIInterfaceOrientationMaskPortrait |UIInterfaceOrientationMaskLandscapeLeft |UIInterfaceOrientationMaskLandscapeRight;
}returnUIInterfaceOrientationMaskPortrait;
}
- (NSUInteger)supportedInterfaceOrientations {
returnUIInterfaceOrientationMaskPortrait |UIInterfaceOrientationMaskLandscapeLeft |UIInterfaceOrientationMaskLandscapeRight;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
returnUIInterfaceOrientationPortrait;
}
//在MPMovieController所在的类里添加/**
* 添加通知监控媒体播放控制器状态
*/-(void)addNotification{NSNotificationCenter*noti = [NSNotificationCenterdefaultCenter];
[noti addObserver:selfselector:@selector(moviePlayerWillEnterFullscreenNotification:)
name:MPMoviePlayerWillEnterFullscreenNotification object:_moviePlayer];
[noti addObserver:selfselector:@selector(moviePlayerWillExitFullscreenNotification:) name:MPMoviePlayerWillExitFullscreenNotification object:_moviePlayer];
}
- (void)moviePlayerWillEnterFullscreenNotification:(NSNotification*)notify
{
AppDelegate *delegate = (AppDelegate *)[[UIApplicationsharedApplication] delegate];
delegate.allowRotation=YES;NSLog(@"moviePlayerWillEnterFullscreenNotification");
}
- (void)moviePlayerWillExitFullscreenNotification:(NSNotification*)notify
{
AppDelegate *delegate = (AppDelegate *)[[UIApplicationsharedApplication] delegate];
delegate.allowRotation=NO;
[self.moviePlayerplay];NSLog(@"moviePlayerWillExitFullscreenNotification");
}
```