UIViewController 实现在旋转时未调用 didRotateFromInterfaceOrientation 的问题
我已经实现了一个继承 UIViewController 的类。我使用 xib 编辑器创建标题栏和工具栏的纵向方向,并且当我旋转 iPad 时它们会正确旋转。不过,我有一个 MPMoviePlayerController,我想使用此方法手动调整其大小:
-(void) didRotateFromInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
_mvp.view.frame = CGRectMake(_titlebar.frame.origin.x , _titlebar.frame.origin.y + _titlebar.frame.size.height , _titlebar.frame.size.width , super.view.frame.size.height - 2* 44);
[_mvp stop];
}
_mvp 是我的 MPMoviePlayerController。我在应用程序的早期使用此方法调整大小并且没有问题,所以我不明白为什么不调用此方法? (因为电影也继续播放)我已经实现了shouldAutoRotateToInterfaceOrientation以返回YES - 这是否会阻止以任何方式运行?
谢谢
I've implemented a class inheriting form UIViewController. I used xib editor to create the portrait orientation of the Titlebar and Toolbar and those rotate correctly when I rotate the iPad. However I have a MPMoviePlayerController which I want to resize manually using this method:
-(void) didRotateFromInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
_mvp.view.frame = CGRectMake(_titlebar.frame.origin.x , _titlebar.frame.origin.y + _titlebar.frame.size.height , _titlebar.frame.size.width , super.view.frame.size.height - 2* 44);
[_mvp stop];
}
_mvp is my MPMoviePlayerController. I resize using this method earlier in the app and have no issue so I don't understand why this method isn't called? (as the movie also continues playing) I have implemented shouldAutoRotateToInterfaceOrientation to return YES - does that prevent this being run in any way?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是因为您的父控制器没有手动将方法调用从 didRotateFromInterfaceOrientation 传递到子控制器。如果您使用 UINavigationController 或 UITabBarController 作为父控制器,您应该看看 这里。
还要确保从所有子视图中向 shouldAutorotateToInterfaceOrientation 返回 YES。
您假设将 shouldAutoRotateToInterfaceOrientation 设置为返回 YES 将不会阻止 didRotateFromInterfaceOrientation 运行。
希望这会有所帮助。
It could be because you have a parent controller that does not manually pass the method call from didRotateFromInterfaceOrientation to the child controllers. If you use a UINavigationController or UITabBarController as your parent controller, you should take a look here.
Also make sure to return YES to shouldAutorotateToInterfaceOrientation from all of your subviews.
Your assumption of setting shouldAutoRotateToInterfaceOrientation to return YES will not prevent didRotateFromInterfaceOrientation from being run.
Hope this helps a little.