简体   繁体   English

使iPhone特定的应用程序在iPad上运行,以满足Apple的要求

[英]Make an iPhone specific app work on iPad to meet Apple requirements

My app has been in the AppStore for a couple of months now and always only worked on iPhone. 我的应用程序已经在AppStore中运行了几个月,并且始终只在iPhone上运行。 I recently submitted an update which was rejected because the App does not run on an iPad. 我最近提交了一个被拒绝的更新,因为该应用程序无法在iPad上运行。 The exact reason it was rejected was: 被拒绝的确切原因是:

Reasons for Rejection: 2.10: iPhone apps must also run on iPad without modification, at iPhone resolution, and at 2X iPhone 3GS resolution 拒绝原因:2.10:iPhone应用程序也必须在iPad上运行,无需修改,iPhone分辨率和2X iPhone 3GS分辨率

What do I need to do in Xcode to make my app run on an iPad in the little box with the 2X icon? 我需要在Xcode中做什么才能让我的应用程序在带有2X图标的小盒子中的iPad上运行?

Any tips instructions will be massively appreciated... 任何提示说明都将受到大力赞赏......

EDIT This is my info.plist. 编辑这是我的info.plist。 This is my first App and I think I did initially chose to set it up with "universal" selected. 这是我的第一个应用程序,我认为我最初选择选择“通用”进行设置。 Is there an easy way back for me to rectify this now? 现在有一个简单的方法让我纠正这个问题吗?

PLIST内容......

Start by figuring out why your app doesn't work on the iPad already. 首先弄清楚为什么你的应用程序不能在iPad上运行。 Most apps developed for the iPhone will work fine on an iPad (in compatibility mode) with no modification; 大多数为iPhone开发的应用程序都可以在iPad上运行(在兼容模式下),无需修改; if yours doesn't, you must be doing something to prevent it. 如果你没有,你必须采取措施防止它。 Are you relying on some hardware feature? 您是否依赖某些硬件功能? Making unfounded assumptions about the device you're running on? 对你正在运行的设备做出毫无根据的假设? How does your app fail when run on an iPad? 在iPad上运行时,您的应用程序如何失败?

Once you've figured out why it doesn't work, you'll be much closer than you are now to fixing the problem. 一旦你弄明白为什么它不起作用,你将比现在更接近解决问题。

To get your app to run on an iPad in iPhone compatibility mode, you need to build your app for iPhone only. 要让您的应用在iPhone兼容模式下在iPad上运行,您需要仅为iPhone构建应用。

Remove all the iPad references from the app's plist (nib base, xib and storyboard), and from the Target Build Settings Targeted Device Family. 从应用程序的plist(nib base,xib和storyboard)以及Target Build Settings Targeted Device Family中删除所有iPad引用。

I had the same issue, I was able to run my app on the ipad after making the following changes. 我有同样的问题,我能够在进行以下更改后在ipad上运行我的应用程序。

  1. in the project settings made the Devices to iPhone(it was universal before) 在项目设置中使设备到iPhone(之前是通用的)
  2. in the .plist removed the main story board file base name related to ipad. 在.plist中删除了与ipad相关的主要故事板文件基本名称。

I have solved same issue using this scenario. 我已经使用这个场景解决了同样的问题。

You should check for normal and retina images in your resources folder. 您应该检查资源文件夹中的正常和视网膜图像。

You may also get this error while debugging Could not load the "image.png" image referenced from a nib in the bundle with identifier . 调试时也可能出现此错误Could not load the "image.png" image referenced from a nib in the bundle with identifier

A normal iPhone app must run on the iPad in both(1x and 2x) mode without modification. 普通的iPhone应用程序必须在(1x和2x)模式下在iPad上运行而无需修改。 You can check this with the SDK Simulator. 您可以使用SDK Simulator进行检查。

There is a long list in the App Store Review Guidelines on Apple's iOS Developer Portal Center which lists many of the things that Apple reviews this things when you submit an app. Apple iOS开发人员门户中心的App Store评论指南中列出了很长的列表,列出了Apple在提交应用程序时审核此内容的许多内容。 Read it carefully. 仔细阅读。

I'll try to explain what my problem and solution was.. 我会尝试解释我的问题和解决方案是什么..

I have an iPhone only app which is mostly in portrait, however, because of 1 or 2 UIViewControllers which have to be in all UIInterfaceOrientations , I have to enable all UIInterfaceOrientations in my plist . 我有一个只有iPhone应用程序,大多数是纵向的,但是,由于1或2个UIViewControllers必须在所有UIInterfaceOrientations ,我必须在我的plist启用所有UIInterfaceOrientations

When starting the app on an iPad which is rotated in landscape and is lying on the table (so has UIDeviceOrientationFaceUp ), the whole app was shown in landscape, which made my UI totally messed up. 当在iPad上启动应用程序时,该应用程序在横向上旋转并且躺在桌子上(因此具有UIDeviceOrientationFaceUp ),整个应用程序以横向显示,这使得我的UI完全搞砸了。

I had no reference to any iPad related code / settings in my plist or launch screens whatsoever (I am using .xcassets for launch screens). 我没有参考我的plist或启动屏幕中的任何iPad相关代码/设置(我使用.xcassets用于启动屏幕)。

I fixed it by adding 1 line of code to my AppDelegate.m which sets the statusbar orientation to force the app in portrait mode. 我通过在我的AppDelegate.m添加一行代码来修复它,它设置状态栏方向以强制应用程序处于纵向模式。

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

    //Further setup
}

I had the same issue using Cocos2d 2.0 我使用Cocos2d 2.0时遇到了同样的问题

My problem was that the project had evolved over several years and had carried along some now vestigial files like RootViewController and UIViewController and MyRootViewController, etc. 我的问题是这个项目已经发展了好几年,并且已经带来了一些现在的遗留文件,如RootViewController,UIViewController和MyRootViewController等。

They worked at the time but clearly had raised a flag with today's review committee because I received the "All iPhone apps must work on the iPad" rejection notice. 他们当时工作,但显然已经与今天的审查委员会举起了旗帜,因为我收到了“所有iPhone应用程序必须在iPad上工作”的拒绝通知。 After screaming out loud and finally accepting defeat, I thought that policy makes it pretty hard to make an app iPhone only. 在大声尖叫并最终接受失败后,我认为该政策使得制作iPhone应用程序非常困难。 Let me know if I am wrong about this. 如果我错了,请告诉我。

Even though I was (and am still) perturbed about it, I thought perhaps now I could at least clean up the project with a more elegant solution that handles the base problem: device rotation + content rotation. 即使我(并且仍然)对此感到不安,我想也许现在我至少可以使用更优雅的解决方案来处理基本问题:设备轮换+内容轮换。 I ended up using something from a more recent project that was working on and seemed more elegant and actually worked: simply add MyNavigationController to the top of my AppDelegate. 我最终使用了一个正在开发的更新项目的东西,似乎更优雅,实际上工作:只需将MyNavigationController添加到我的AppDelegate顶部。

I have added the code below. 我在下面添加了代码。 I am sure it can be improved. 我相信它可以改进。 Please comment if you can enhance it. 如果你可以加强它,请评论。

As a result, I was able to delete the old RootViewController and MyRootViewController files so now it's easier to maintain. 结果,我能够删除旧的RootViewController和MyRootViewController文件,所以现在它更容易维护。 I never understood their purpose very well anyways. 无论如何,我从未理解过他们的目的。 Good riddance! 甩掉包袱!

Here is my solution to displaying and matching device orientation + content orientation: 以下是我显示和匹配设备方向+内容方向的解决方案:

in AppDelegate.h I had to declare what I was doing: 在AppDelegate.h中我必须声明我在做什么:

//top of the file //文件顶部

@interface MyNavigationController : UINavigationController @end @interface MyNavigationController:UINavigationController @end

//inside AppDelegate.h interface //在AppDelegate.h界面内

MyNavigationController *navController_; MyNavigationController * navController_;

//bottom of the file before @end // @end之前的文件底部

@property (readonly) MyNavigationController *navController; @property(readonly)MyNavigationController * navController;

Here is the code that works at the top of my AppDelegate.m 这是在我的AppDelegate.m顶部工作的代码

@implementation MyNavigationController @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

Here is why I had to solve this: 这就是我必须解决这个问题的原因:

  1. I needed both Landscape and Portrait modes to display different scenes. 我需要横向和纵向模式来显示不同的场景。

Here are some screenshots that describe the situation 以下是一些描述情况的屏幕截图

JR化学套装

大多数应用方向都是这张照片所示的风景

其他区域仅在您转动设备时触发

一个2个应用程序!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM