我正在以编程方式创建一个MPMoviePlayerView。我的PlayerView自动旋转在iOS 5中工作正常但在iOS 6和iOS 7中不起作用。我尝试添加方向检测,但问题仍然存在。
任何人都可以告诉我如何在iOS 5,iOS 6和iOS 7中支持自动轮换。
谢谢,
答案 0 :(得分:0)
尝试在AppDelegate中实现此方法:
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
}
你可以为这两种模式制定条件。
如果媒体播放器全屏显示,那么
返回UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; 否则返回UIInterfaceOrientationMaskPortrait;
感谢
答案 1 :(得分:0)
[[UIApplication sharedApplication] statusBarOrientation];
[[UIDevice currentDevice] orientation];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceRotatedEventList:) name:UIDeviceOrientationDidChangeNotification object:nil];
-(void)deviceRotatedEventList:(NSNotification*)notification
{
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
//Do your stuff for landscap
}
else if(orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
{
}
}
//对于旋转方法,编写代码肖像和横向模式,无论........