【发布时间】:2012-07-09 06:32:49
【问题描述】:
我正在为 iPad 创建横向应用程序,但是当我运行该应用程序时,我发现主屏幕显示为纵向。我该如何解决?
【问题讨论】:
我正在为 iPad 创建横向应用程序,但是当我运行该应用程序时,我发现主屏幕显示为纵向。我该如何解决?
【问题讨论】:
选择目标,在“支持的设备方向”中仅选择横向左和横向右选项。以及在您的 roo 视图控制器集中
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(UIInterfaceOrientationIsLandscape(interfaceOrientation))
return YES;
return NO;
}
【讨论】:
确保您的应用在项目设置中仅支持横向(取消选择“纵向”和“倒置”):
支持横向的视图控制器也应该说他们支持:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
【讨论】:
添加这个方法
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
NSLog(@"Changed interface orientation");
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight)
);
}
【讨论】: