0

this code is in my app delegate.....

@implementation AppDelegate

- (UIStoryboard *)grabStoryboard {

    UIStoryboard *storyboard;

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

    if (height == 480) {
        storyboard = [UIStoryboard storyboardWithName:@"Main3.5" bundle:nil];
        // NSLog(@"Device has a 3.5inch Display.");
    } else if (height == 568) {
        storyboard = [UIStoryboard storyboardWithName:@"Main4.0" bundle:nil];
        // NSLog(@"Device has a 4inch Display.");
    }else {
        storyboard = [UIStoryboard storyboardWithName:@"Main7.0" bundle:nil];
        // NSLog(@"Device is ipad.");
    }

    return storyboard;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary      *)launchOptions
{
    UIStoryboard *storyboard = [self grabStoryboard];

    // show the storyboard
    self.window.rootViewController = [storyboard instantiateInitialViewController];
    [self.window makeKeyAndVisible];

    return YES;
}

this is how my app is working on all iOS devices except the iPhone 6 and 6 plus. what do i need to add to make the iPhone 6 and 6 plus to work as well. incase it helps. if it helps this is how i separate the coding when needed on my view controllers.

#define IS_IPAD (( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) ? YES : NO)
#define IS_IPHONE_5 (([UIScreen mainScreen].scale == 2.f && [UIScreen      mainScreen].bounds.size.height == 568)?YES:NO)
#define IS_RETINA_DISPLAY_DEVICE (([UIScreen mainScreen].scale == 2.f)?YES:NO)

if (IS_IPAD)
{
    //do stuff for iPad
    text.text = [NSString stringWithFormat:@"i am an ipad"];
}
else
{
    if(IS_IPHONE_5)
    {
        //do stuff for 4 inch iPhone screen
        text.text = [NSString stringWithFormat:@"i am an iphone 5 or 5s"];
    }
    else
    {
        //do stuff for 3.5 inch iPhone screen
        text.text = [NSString stringWithFormat:@"i am an iphone 4 or lower"];
    }

}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
meno
  • 21
  • 3
  • You should dump all of your screen checks and use a single resizable storyboard for all devices. – Desdenova Oct 04 '14 at 08:09
  • How would i go on about doing that. any tutorials and how would i separate code for different size story boards. Would it all just use the same pixel positioning and resize that as well. – meno Oct 04 '14 at 18:32

1 Answers1

0

Paste this code in your AppDelegate.m

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:(v) options:NSNumericSearch] != NSOrderedAscending)

and below code in application didFinishLaunchingWithOptions:

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")){
     mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil]; }
Ajith Renjala
  • 4,934
  • 5
  • 34
  • 42
user2776957
  • 25
  • 1
  • 8
  • thanks for your suggestion but in the end auto layout on my view controllers were turned on when i updated Xcode wich was the reason why my game was acting weird. after turning it off everything seems to work in the emulator for iPhone 6 and 6 plus. – meno Oct 04 '14 at 19:06