Search code examples
iphoneobjective-cresolutionscreen-size

iPhone 5: Want to find out Screen size for iPhone 5


I am wondering how i can detect using the screen size is iPhone 5. My application at the moment using 3.5 inch interface on a iPhone 5 so when I used the code

CGSize result = [[UIScreen mainScreen] bounds].size;

This gave me 400 instead of 568 height of the screen size. Is that because I am using 3.5 inch interface on a iPhone 5. I know i need to change the layout of the application but due to our time constraint I wanted to keep it that way.

Or Do I need to get the scale factor to get the real pixel

CGFloat screenScale = [[UIScreen mainScreen] scale];

Please help...


Solution

  • you can easly detect iphone, iphone5 and iPad with below condition:-

     if([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPhone)
     {
         if ([[UIScreen mainScreen] bounds].size.height == 568)
         {
    
    
         }
         else
         {
             //iphone 3.5 inch screen
         }
     }
     else
     {
            //[ipad]
     }
    

    just visit my answer at this Detect device type