Posts Tagged ‘universal’

Project Code for Universal App Creation

Posted in code on March 29th, 2012 by admin – Be the first to comment

Step 1

In your Target Info set the Targeted Device Family to “iPhone/iPad”

Step 2

In your appDelegate.m put this bit of code

 - (BOOL) isIpad {
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        return YES;
    } else {
        return NO;
    return NO;

To reference it in your other classes do this

in class.h

@interface YourLayerClass : CCLayer {
    YourAppDelegate *theDelegate;
    Boolean *isIpad;

in class.m in your init method

-(id) init
    if( (self=[super init] )) {

                //DEFINE iPad or iPhone
        theDelegate = (YourAppDelegate*)[[UIApplication sharedApplication] delegate];
        isIpad = [theDelegate isIpad];


And you can use it in your class thusly

    if(isIpad == NO){
    bg = [CCSprite spriteWithFile:@"xx_iphone.png"];
    }else {
    bg = [CCSprite spriteWithFile:@"xx_ipad.png"];