[英]iPad app force rotation
I have a simple navigation app that has 95% of all views displayed in landscape mode. 我有一个简单的导航应用程序,其中95%的视图以横向模式显示。 With the one view that makes sense to only show in Portrait mode i have inserted the following code in:
通过仅在纵向模式下显示的一个视图,我在其中插入了以下代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
The problem is that when the app navigates to the view (from a landscape orientated view) it does not switch the orientation to portrait, only when the device is rotated will it snap into portrait and stay in portrait. 问题在于,当应用程序导航到视图(从横向视图)时,它不会将方向切换为纵向,只有当设备旋转时,它才会捕捉到纵向并保持纵向。 Is it possible to force it to load in portrait mode on load of the view?
是否可以在视图加载时强制其以纵向模式加载?
Thanks in advane 感谢先进
I think you should go through : shouldAutoRotateToInterfaceOrientation
method of UIViewController
Class. 我认为您应该通过:
UIViewController
类的shouldAutoRotateToInterfaceOrientation
方法。
This function returns YES if the orientations is supported by your UIView. 如果UIView支持方向,则此函数返回YES。 If you
return YES
only to the portrait orientation
, then the iPhone will automatically be put in that orientation. 如果仅对
portrait orientation
return YES
,则iPhone将自动以该方向放置。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.