仅支持iPad竖屏显示?

3

根据苹果公司的要求,我的应用程序必须能够在两种纵向模式下运行。我该如何使用shouldAutorotateToInterfaceOrientation来实现这一点?

4个回答

8
无论接口方向如何,都请返回 YES。这将允许系统自动旋转到倒置的方向。
如果您不想支持横向方向,则请返回:
return UIInterfaceOrientationIsPortrait(interfaceOrientation);

我不希望用户能够在横屏模式下玩游戏,因为它无法正常工作。我只想要两个竖屏模式。 - NextRev

6
这段代码允许除横向以外的任何方向:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
    return (orientation != UIDeviceOrientationLandscapeLeft) &&
           (orientation != UIDeviceOrientationLandscapeRight);
}

1

由于上述原因,提交的应用程序被拒绝。该应用程序仅使用纵向(Home键朝下)方向。

“应用程序不符合苹果iOS人机界面指南的要求,这是App Store审核指南所必需的。

具体而言,该应用程序仅支持纵向底部向上的变体,而不支持顶部向上的变体。

虽然支持每个方向的两个变体,且每个变体都有独特的启动图像,可以提供最佳用户体验并得到推荐,但我们理解某些应用程序必须仅在纵向方向上运行。在这种情况下,适当的做法是在您的应用程序中支持该方向的两个变体,例如,Home键朝上和朝下。”

解决方法: 1)

 `- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}

2) 打开 info.plist 添加一个新的字符串 UILaunchImageFile 并将值插入为 Default-Portrait.png

3) 将 Default.png 更改为 Default-Portrait.png,并复制该文件以重命名为 Default-PortraitUpsideDown.png(将此文件旋转 180 度)

这将启用上下方向的肖像模式,具有相应的启动图像。

确保在应用程序内的所有视图控制器中使用 UIInterfaceOrientationIsPortrait(interfaceOrientation),如果需要的话。在运行之前进行清理操作。


1
请使用这个。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

为了提高您的回答质量,请说明您的帖子如何/为什么解决问题。 - Mick MacCallum

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接