user3750268
user3750268

Reputation: 11

Made iPhone app with 4" dimensions, how to make universal?

I've made an app for the iPhone, and everything has the iPhone5 4" dimensions. The simulator runs the game fine, and it works great on my iPhone.

Now, I understand that in order to release the game on iPhone 3.5" screens and iPad, I must create files within the same project file.

I have:

  1. Iphone4":

    • main.h
    • main.m
    • iphone4".storyboard
    • other.h
    • other.m
  2. Iphone3.5":

    • main1.h
    • main1.m
    • iphone3.5".storyboard
    • other1.h
    • other1.m
  3. Ipad:

    • main2.h
    • main2.m
    • ipad.storyboard
    • other2.h
    • other2.m

I have a number of questions:

  1. How does the the downloaders device detect what folder to take the game from?

  2. When I run the simulator in 3.5", despite having created the app in 3.5" settings, it still sources the storyboard created in the 4" folder. However, when I run the iPad simulator it runs the storyboard in the iPad folder. So in short, how do I get Xcode to detect when it should use 4" dimensions in the simulator or when to use the 3.5" dimensions?

  3. If I were to release the app on the App Store as a 4" game, will anyone that downloads it on an iPhone4 or older still be able to play it (i.e will it auto rescale?)

Happy to discuss further over Skype or other medium. Would be grateful for a quick response.

Kind regards,

Max

Upvotes: 1

Views: 87

Answers (2)

user3078856
user3078856

Reputation:

You are using Storyboards, so do this is your app delegate

- (UIStoryboard *)grabStoryboard {

UIStoryboard *storyboard;

// detect the height of our screen
int height = [UIScreen mainScreen].bounds.size.height;

if (height == 480) {
    storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    // NSLog(@"Device has a 3.5inch Display.");
} else {
    storyboard = [UIStoryboard storyboardWithName:@"MainRetina" bundle:nil];
    // NSLog(@"Device has a 4inch Display.");
}

return storyboard;

}

then in your view did load add this:

UIStoryboard *storyboard = [self grabStoryboard];

and if you are using iPad add in the size for that and rename your storyboards to that effect

Upvotes: 2

Duncan C
Duncan C

Reputation: 131501

You do not have to, and should not, have different source files for the different platforms. It's quite straightforward to make the 3.5" and 4" iPhone/iPods run from the same storyboard.

You generally DO want a different storyboard for iPad and iPhone. The info tab in your project has spaces for both filenames, and at runtime, the app decides which one to load automatically.

The rules are changing with iOS 8 however. If this is a new app that's still under development, you might want to think about using the new adaptive UI functions built into iOS 8. Apple has pretty radically changed the way they expect us to handle this stuff, as well as the way we're supposed to handle device rotation (short answer: we're NOT supposed to handle rotation any more. Instead, we get notified about size changes in our views and we're supposed to respond to those. Now there are "size classes" that have states of "regular" and "compact" for each dimension, and you teach your app how to lay itself out in the different combinations of regular and compact sizes.

Apple has strongly hinted that new device sizes are coming, and that we should adopt the new way of doing things if we want to work correctly with the new devices. It's pretty likely that any new devices will only run iOS 8, and will depend on the new adaptive UI APIs for their UI layouts. I don't know what kind of compatibility they will have with older devices, but it will likely have limitations.

Upvotes: 0

Related Questions