【发布时间】:2011-05-30 19:19:57
【问题描述】:
所以我已经尝试在我的 iPad 应用程序的 Info.plist 中设置 Supported Interface Orientations 键以支持两种横向模式。但是,当我将 iPad 纵向放置时,我的屏幕会旋转。由于我的应用程序的设计方式,我只希望我的应用程序以任一横向模式显示,我该怎么做?
【问题讨论】:
所以我已经尝试在我的 iPad 应用程序的 Info.plist 中设置 Supported Interface Orientations 键以支持两种横向模式。但是,当我将 iPad 纵向放置时,我的屏幕会旋转。由于我的应用程序的设计方式,我只希望我的应用程序以任一横向模式显示,我该怎么做?
【问题讨论】:
设置Info.plist 键主要用于确定应用启动时的方向。如果您的视图控制器从shouldAutorotateToInterfaceOrientation: 返回给定方向的YES,则无论Info.plist 说什么,接口都将被允许以这种方式定位。解决方案是在该方法中只允许横向:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
return UIInterfaceOrientationIsLandscape(orientation);
}
【讨论】:
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
【讨论】: