How can I detect the iphone 5 screen size in my app? *Help*

Discussion in 'iOS Programming' started by iJustinCabral, Oct 4, 2012.

  1. iJustinCabral macrumors member

    iJustinCabral

    Joined:
    Jul 8, 2012
    #1
    I know there is something like CGRect homeScreen = [[UIScreen mainScreen] bounds]; but I dont really understand what else to do with what is returned.

    Can anyone out there give me some guidance?
     
  2. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #2
    Given these definitions -

    Code:
    struct CGPoint {
      CGFloat x;
      CGFloat y;
    };
    typedef struct CGPoint CGPoint;
    
    /* Sizes. */
    
    struct CGSize {
      CGFloat width;
      CGFloat height;
    };
    typedef struct CGSize CGSize;
    
    /* Rectangles. */
    
    struct CGRect {
      CGPoint origin;
      CGSize size;
    };
    typedef struct CGRect CGRect;
    
    the statement -

    Code:
    CGRect homeScreen = [[UIScreen mainScreen] bounds];
    
    gives the width and height of the screen as -

    Code:
    CGFloat width = homeScreen.size.width;
    CGFloat height = homeScreen.size.height;
    
     

Share This Page