使用MPMoviePlayerViewController时的iPad旋转错误 [英] iPad rotation bug when using MPMoviePlayerViewController

查看:83
本文介绍了使用MPMoviePlayerViewController时的iPad旋转错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题摘要



使用MPMoviePlayerViewController播放视频时更改iPad设备或模拟器的方向会导致视频播放器关闭时旋转状态不一致。这是iPad SDK 3.2中的已知错误,记录在 http://www.openradar.me/8012810



示例项目


$ b $ p我已经使用Xcode 3.2中的基于视图的应用程序模板准备了一个最小示例项目.2,使用以下代码启动播放器

  NSURL * movieUrl = [NSURL URLWithString:@http:// devimages .apple.com / iphone / samples / bipbop / bipbopall.m3u8]; 
MPMoviePlayerViewController * player = [[MPMoviePlayerViewController alloc] initWithContentURL:movieUrl];
[self presentMoviePlayerViewControllerAnimated:player];
[player release];

此代码可在GitHub上获得, http://github.com/adamalex/FullScreenMovie 或使用 http://github.com/adamalex/FullScreenMovie/zipball/master



重现步骤




  1. 使用上述信息获取项目

  2. 使用iPad模拟器或设备启动项目
  3. $ b $ b
  4. 请注意UIStatusBar与应用程序UI不同步



目标


$ b b

我已经联系苹果,他们已经确认这是一个正在调查的错误。我想讨论使用公共API安全提交到App Store的临时解决方法。

解决方案

成功响应来自于苹果的开发者支持案例Apple开发者技术支持!


这是一个已知的错误,我们收到了一些重复的错误报告,所以iOS工程意识到的问题,我们有一个临时的解决方案,由iOS工程建议。



您将需要在提供电影播放器​​的视图控制器中实现此功能。




   - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation] ;
[self performSelector:@selector(fixStatusBar)withObject:nil afterDelay:0];
}

- (void)fixStatusBar {
[[UIApplication sharedApplication] setStatusBarOrientation:[self interfaceOrientation] animated:NO];
}




虽然这有点丑陋,现在的问题。一旦错误在系统中修复,建议删除此代码。


这完全为我处理了这个问题,并且您可以重新访问 http://github.com/adamalex/FullScreenMovie 应用修复的代码。


Issue summary

Changing the orientation of an iPad device or simulator while playing a video using MPMoviePlayerViewController results in an inconsistent rotation state upon dismissal of the video player. This is a known bug in iPad SDK 3.2, documented at http://www.openradar.me/8012810

Sample project

I have prepared a minimal sample project using the View-based Application template from Xcode 3.2.2, using the following code to launch the player

NSURL *movieUrl = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
MPMoviePlayerViewController *player = [[MPMoviePlayerViewController alloc] initWithContentURL:movieUrl];
[self presentMoviePlayerViewControllerAnimated:player];
[player release];

The code is available on GitHub at http://github.com/adamalex/FullScreenMovie or direct download using http://github.com/adamalex/FullScreenMovie/zipball/master

Steps to reproduce

  1. Obtain the project using the information above
  2. Launch the project with the iPad simulator or device
  3. Tap the button to begin playing the video
  4. Rotate the iPad by 90 degrees
  5. Dismiss the video
  6. Note the UIStatusBar is out of sync with the application UI

Objective

I have contacted Apple and they have confirmed this is a bug that is being investigated. I would like to discuss temporary workarounds that use public APIs safe for submission to the App Store. I am going to open a developer support case with Apple as well and will report back with my own progress.

解决方案

Successful response from Apple Developer Technical Support!

This is a known bug and a we're received a number of duplicate bug reports and so iOS engineering is aware of the issue and we do have a temporary workaround as suggested by iOS engineering.

You will need to implement this in the view controller which presents the movie player.

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
   [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
   [self performSelector:@selector(fixStatusBar) withObject:nil afterDelay:0];
}

- (void)fixStatusBar {
   [[UIApplication sharedApplication] setStatusBarOrientation:[self interfaceOrientation] animated:NO];
}

While this is somewhat ugly, it should fix the issue for now. It would be recommended to remove this code once the bug is fixed in the system.

This took care of the issue completely for me, and you can revisit http://github.com/adamalex/FullScreenMovie for the code with the fix applied.

这篇关于使用MPMoviePlayerViewController时的iPad旋转错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆