Checking for different devices

Discussion in 'iOS Programming' started by V-Appel, Jun 23, 2014.

  1. V-Appel macrumors newbie

    Joined:
    Oct 1, 2013
    #1
    I´m trying to check if the device is an iPhone or an iPad and it´s working. I´m just checking with:

    Code:
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){         NSLog(@"its an iPad");
     }
    
    But I want to use this for setting some different int values so different things location is costume to what ever device they are using. But my values in this example aren´t beeing set... So all locations equals 0 when I run it and everything ends up in one spot...

    Code:
     else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
           
     NSLog(@"its an iPhone");
            yCord = 70; 
            xCord = 20;
    }
    
    This if statment is located in my
    Code:
    -(id)initWithSize:(CGSize)size 
    method.
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Can you provide us with the more of the code for initWithSize:, especially the if part before the else-if? Also, how and where are you declaring xCord and yCord? And where / how are you using their values?
     
  3. JohnsonK macrumors regular

    Joined:
    Mar 6, 2014
    #3
    You have to be aware that the best place to set frame is inside the viewDidLayoutSubviews method
     

Share This Page