让iPhone专用应用在iPad上运行以满足苹果的要求

13

我的应用程序已经在AppStore中运行了几个月,一直只能在iPhone上工作。最近我提交了更新,但被拒绝了,因为该应用程序无法在iPad上运行。被拒绝的确切原因是:

拒绝理由: 2.10:iPhone应用程序必须在iPad上以iPhone分辨率和2倍iPhone 3GS分辨率的形式运行,而无需进行修改

我需要在Xcode中做什么才能让我的应用程序在带有2X图标的小框中在iPad上运行?

任何提示或指示都将不胜感激...

编辑 这是我的info.plist。这是我的第一个应用程序,我认为我最初选择使用“通用”设置进行设置。现在是否有简单的方法可以纠正这个问题?

PLIST contents...


你尝试在iPad模拟器上运行它了吗?你有@2x的图片吗? - Jamie
6个回答

10

首先要弄清楚为什么您的应用程序无法在iPad上正常工作。大多数为iPhone开发的应用程序都可以在iPad上(兼容模式下)完美运行,无需修改;如果您的应用程序无法正常工作,则必须有一些原因导致这种情况。您是否依赖某些硬件功能?对正在运行的设备做出了未经证实的假设?当在iPad上运行时,您的应用程序如何失败?

一旦确定了问题所在,您就比现在更接近解决问题了。


这正是我所想的,但我将当前版本下载到我的iPad上,却得到了默认的UITabBar“First View”和“Second View”。我没有使用任何硬件功能。我的应用程序是一个简单的应用程序,用于捕获运动员训练会话的详细信息。所有数据都在文本字段中捕获并存储在核心数据中。是否有Xcode设置我应该检查? - Sean
4
你是否将应用程序设置为通用应用程序(即能够正常运行在不同设备上),而没有实现对iPad的支持?如果不是,请说明原因,我有点不理解。你的Info.plist文件中包含什么信息? - Caleb
1
感谢所有的评论。请原谅我,因为这是我第一次编写并成功提交到AppStore的应用程序。我已经编辑了原始问题并添加了PLIST内容。我认为我最初设置它为通用应用程序,而没有意识到这一点。有没有简单的方法来反转这个过程,以便我的应用程序将按照Apple的要求作为iPhone应用程序在iPad上运行? - Sean
6
Caleb,你上面的评论最终让我找到了解决方法。对于其他人,如果遇到这个问题,我将解释我是如何纠正这种情况的。我编辑了我的 info.plist 文件并删除了三个与 iPad 相关的键(你可以在我编辑后的问题中看到这些键)。然后重新编译,现在 iPad 不再打开一个空的 iPad storyboard,而是打开 iPhone storyboard。这就是我所需要做的全部。我很欣慰——一度以为我必须从头开始重建……再次感谢 Caleb! - Sean

7
为了让您的应用在iPad上以iPhone兼容模式运行,您需要仅为iPhone构建应用程序。 从应用程序的plist(nib base、xib和storyboard)以及目标构建设置的目标设备系列中删除所有iPad引用。

天啊,我希望这真的能够运行,否则我就不知道该怎么办了。 - temporary_user_name

4

我曾经遇到过同样的问题,后来通过以下更改之后成功在iPad上运行了我的应用:

  1. 在项目设置中将设备选项更改为iPhone(之前是通用的)
  2. 在.plist文件中删除与iPad相关联的主storyboard文件名称。

1
谢谢,它对我很有帮助! - Vidhyanand

1

我将尝试解释我的问题和解决方案。

我的应用程序只能在 iPhone 上使用,它大多数是以纵向模式展示的。但是,由于其中有1或2个UIViewControllers 必须以所有UIInterfaceOrientations 模式展示,因此我不得不在plist中启用所有UIInterfaceOrientations 模式。

当我在桌子上横放旋转了的iPad(所以具有UIDeviceOrientationFaceUp)上启动应用程序时,整个应用程序都以横向模式展示,这使得我的UI布局完全错乱了。

我的plist或启动屏幕中没有任何与iPad相关的代码/设置参考(我正在使用.xcassets作为启动屏幕)。

我通过在我的AppDelegate.m中添加了1行代码来解决这个问题,该代码将状态栏方向设置为强制将应用程序置于纵向模式。

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];

    //Further setup
}

1

我使用以下方案解决了同样的问题。

您应该在资源文件夹中检查普通和Retina图像。

在调试时,您可能会遇到此错误Could not load the "image.png" image referenced from a nib in the bundle with identifier

普通的iPhone应用程序必须在iPad上以(1x和2x)模式运行,无需修改。您可以使用SDK模拟器进行检查。

在苹果iOS开发者门户中的App Store审核指南中有一个长列表,列出了许多苹果在您提交应用时审查的事项。请仔细阅读。


0

我在使用Cocos2d 2.0时遇到了同样的问题。

我的问题是,这个项目已经发展了几年,并携带了一些现在已经过时的文件,如RootViewController、UIViewController和MyRootViewController等。它们当时可以工作,但显然引起了今天审查委员会的注意,因为我收到了“所有iPhone应用程序必须在iPad上运行”的拒绝通知。在大声喊叫并最终接受失败后,我认为这个政策使得制作一个仅限于iPhone的应用程序变得非常困难。如果我对此有误,请告诉我。

尽管我当时(现在仍然)感到不安,但我想也许现在我至少可以用更优雅的解决方案来清理项目,处理基本问题:设备旋转+内容旋转。最终,我使用了从一个更近期的项目中借鉴的东西,它看起来更加优雅,而且实际上也起作用:只需将MyNavigationController添加到我的AppDelegate的顶部即可。

我已经添加了下面的代码。我相信它可以改进。如果您能增强它,请评论。

因此,我能够删除旧的RootViewController和MyRootViewController文件,现在更容易维护。我从来没有真正理解它们的目的。好了,终于摆脱了!

这是我显示和匹配设备方向+内容方向的解决方案:

在AppDelegate.h中,我必须声明我正在做什么:
//文件顶部 @interface MyNavigationController : UINavigationController @end
//在AppDelegate.h接口内部 MyNavigationController *navController_;
//在@end之前的文件底部 @property (readonly) MyNavigationController *navController;
这是在我的AppDelegate.m顶部工作的代码:
@implementation MyNavigationController
// The available orientations should be defined in the Info.plist file.
// And in iOS 6+ only, you can override it in the Root View controller in the "supportedInterfaceOrientations" method.
// Only valid for iOS 6+. NOT VALID for iOS 4 / 5.

-(NSUInteger)supportedInterfaceOrientations {

UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];

if (orientation == UIDeviceOrientationPortrait) {

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {

        // [director_ pushScene: [IPAD scene]];

    } else {

        [[CCDirectorIOS sharedDirector] pushScene:[VerticalDisplayLayer scene]];

        return UIInterfaceOrientationMaskPortrait;

    }


} else if (orientation == UIDeviceOrientationLandscapeLeft) {


    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {

       //  [director_ pushScene: [IPAD scene]];

    } else {

        [[CCDirectorIOS sharedDirector] pushScene:[MainMenuScene scene]];

    }



} else if (orientation == UIDeviceOrientationLandscapeRight) {


    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {

        // [director_ pushScene: [IPAD scene]];

    } else {

        [[CCDirectorIOS sharedDirector] pushScene:[MainMenuScene scene]];

    }


} else if (orientation == UIDeviceOrientationPortraitUpsideDown) {

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {

    } else {

        [[CCDirectorIOS sharedDirector] pushScene:[VerticalDisplayLayer scene]];

        return UIInterfaceOrientationMaskPortraitUpsideDown;

    }

} else {

    //do nothing
}

return UIInterfaceOrientationMaskLandscape;

}

//this is the one for iOS 6
- (BOOL)shouldAutorotate {

//NSLog(@"MyNavigationController - should Rotate ToInterfaceOrientation ...");

UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];

// iPhone only
if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ) {

    //NSLog(@"MyNavigationController - should Rotate iPhone");

    if (orientation == UIDeviceOrientationPortrait) {

        //NSLog(@"should Rotate iPhone orientation is Portrait");

        [[CCDirectorIOS sharedDirector] pushScene:[VerticalDisplayLayer scene]];

        return UIInterfaceOrientationMaskPortrait;

    }

    if (orientation == UIDeviceOrientationPortraitUpsideDown) {

        //NSLog(@"should Rotate iPhone orientation is PortraitUpsideDown");

        [[CCDirectorIOS sharedDirector] pushScene:[VerticalDisplayLayer scene]];

        return UIInterfaceOrientationMaskPortraitUpsideDown;

    }

    if (orientation == UIDeviceOrientationLandscapeLeft) {

        //NSLog(@"should Rotate iPhone orientation is Landscape Left");

        return UIInterfaceOrientationMaskLandscape;
    }

    if (orientation == UIDeviceOrientationLandscapeRight) {

        //NSLog(@"should Rotate iPhone orientation is Landscape Right");

        return UIInterfaceOrientationMaskLandscape;
    }


    return TRUE;

}

//return UIInterfaceOrientationIsLandscape(interfaceOrientation);

if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad ) {

    //NSLog(@"MyNavigationController - should Rotate iPad");

    return TRUE;

}


return TRUE;
}


// Supported orientations. Customize it for your own needs
// Only valid on iOS 4 / 5. NOT VALID for iOS 6.
- (BOOL)shouldAutorotateToInterfaceOrientation:    (UIInterfaceOrientation)interfaceOrientation
{

// iPhone only
if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone )


    return TRUE;
//return UIInterfaceOrientationIsLandscape(interfaceOrientation);


if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad )

    return TRUE;

// iPad only
// iPhone only
//return UIInterfaceOrientationIsLandscape(interfaceOrientation);

return TRUE;
}

// This is needed for iOS4 and iOS5 in order to ensure
// that the 1st scene has the correct dimensions
// This is not needed on iOS6 and could be added to the application:didFinish...
-(void) directorDidReshapeProjection:(CCDirector*)director
{
if(director.runningScene == nil) {
    // Add the first scene to the stack. The director will draw it immediately into the framebuffer. (Animation is started automatically when the view is displayed.)
    // and add the scene to the stack. The director will run it when it automatically when the view is displayed.
    [director runWithScene: [MainMenuScene scene]];
}
}


-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
// Assuming that the main window has the size of the screen
// BUG: This won't work if the EAGLView is not fullscreen

CGRect screenRect = [[UIScreen mainScreen] bounds];
CGRect rect = CGRectZero;

//NSLog(@"MyNavigationController - Will RotateToInterfaceOrientation ...");

if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)  {

    rect = screenRect;


} else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {

    rect.size = CGSizeMake( screenRect.size.height, screenRect.size.width );

}

CCDirector *director = [CCDirector sharedDirector];
CCGLView *glView = (CCGLView *)[director view];
glView.frame = rect;
}

@end

以下是我必须解决这个问题的原因:

  1. 我需要横向和纵向模式来显示不同的场景。

以下是一些截图,描述了这种情况。

JR Chemistry Set

most of the app orientation is landscape like this photo shows

other areas were only triggered when you turned the device

2 apps in one!


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