iosipadretina-displayipad-mini

ipad mini retina wrong screen resolution


I can't take good results when I try to read resolution of my device.

Such code

 CGRect screenRect = [[UIScreen mainScreen] bounds];
     CGFloat screenWidth = screenRect.size.width;
     CGFloat screenHeight = screenRect.size.height;
     NSString* name = [self machineName];

gives

1024*768 and iPad4,5

machineName code:

#import <sys/utsname.h>
-(NSString*) machineName()
{
    struct utsname systemInfo;
    uname(&systemInfo);

    return [NSString stringWithCString:systemInfo.machine
                              encoding:NSUTF8StringEncoding];
}

What am I doing wrong? I can't understand. It must be 2048*1536


Solution

  • Bound returns the screen dimensions in points.

    You need to query CGFloat scale = [[UIScreen mainScreen] scale];

    and multiply this by the width/height to get the pixel value