系统忽略iPhone旋转 [英] System ignore iPhone rotation

查看:154
本文介绍了系统忽略iPhone旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在UIApplication中是否有一个像beginIgnoringInteractionEvents这样的功能,忽略了旋转而不是触摸?我需要我的应用程序,不要旋转,只是在我现在的 MPMovePlayerViewController 中。

Is there a function like beginIgnoringInteractionEvents in UIApplication that ignores rotation instead of touches? I need my app NOT to rotate just in an MPMovePlayerViewController that I present.

谢谢

[更新]

这是我的代码 -

MPMoviePlayerViewController *mpViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:videoURL]];
[mpViewController shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
[self presentMoviePlayerViewControllerAnimated:mpViewController];
[mpViewController release];

通过添加shouldAutorotateToInterfaceOrientation:和setStatusBarOrientation:方法,我可以正常工作。它在模拟器中工作。但是,如果我在播放视频时旋转iPhone,状态栏也会旋转,并以纵向方向保持卡住。

I got it working by adding both the shouldAutorotateToInterfaceOrientation: and setStatusBarOrientation: methods. It works in the simulator. However if I rotate the iPhone while the video is playing, the status bar rotates as well and stays 'stuck' in the portrait orientation.

我的问题的形象在 http://i28.tinypic.com/357mrub.png

[更新2]

通过对MPMoviePlayerViewController进行子类化(并实现shouldAutorotate方法),程序会按原样旋转。只有视频不能播放,因为

By subclassing MPMoviePlayerViewController (and implementing the shouldAutorotate method), the program rotates as it should. Only the video doesn't play because the line

[self presentMoviePlayerViewControllerAnimated:mpViewController];

不接受我的子类。

不兼容的Objective-C类型结构NoRotate *',当从不同的Objective-C类型传递'presentMoviePlayerViewControllerAnimated:'的参数1时,预期'struct MPMoviePlayerViewController *'$

"warning: incompatible Objective-C types 'struct NoRotate *', expected 'struct MPMoviePlayerViewController *' when passing argument 1 of 'presentMoviePlayerViewControllerAnimated:' from distinct Objective-C type"

推荐答案

在您提出的视图中,实现shouldAutoRotate方法,只需返回否。这将导致手机忽略任何和所有方向的更改。

In the view you present, implement the shouldAutoRotate method and simply return "NO". This will cause the phone to ignore any and all orientation changes.

这篇关于系统忽略iPhone旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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