加载后旋转视图
在我的一个应用程序中,我实现了一个可以播放电影的视图。视图的方向是纵向。我重写了以下方法,以便在电影播放后视图会旋转。
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (isPlayingMovie) {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft );
} else {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
}
问题是视图不会自动旋转。我认为视图仅在加载时在视图控制器中调用此方法,但我如何强制他再次调用它?
提前致谢。
In one of my applications I implemented a view that can play a movie. the oriantation of the view is Portrait. I overwrite the foloowing method so the view will rotate once the movie is playing.
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (isPlayingMovie) {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft );
} else {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
}
The problem is that the view will not automatically rotate. I figured that the view calles this method in the view controller only while it's loading but how can i force him to call it again ?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简短的回答:不可能。
长答案:只需返回您仅进行纵向并自行旋转视图即可。
获取旋转通知(将其放在 viewDidAppear 或其他内容中):
然后在“rotationChange:”中进行旋转(此处为 webview 的示例):
编辑:如果不需要通知,请不要忘记禁用通知(例如“ viewDidDisappear:”)
Short answer: not possible.
Long answer: Just return that you do portrait only and rotate the view yourself.
Get rotation notifications (put it in viewDidAppear or something):
Then do the rotation in "rotationChange:" (example for a webview here):
EDIT: Don't forget to disable the notifications if you don't need them (like in "viewDidDisappear:")
尝试使用此方法中的代码
干杯
Try using the code in this method
Cheers