Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone 3.5 Inch screen - 4 inch screen:

I know you can choose ipad or iphone by using an if statement with UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad. But I was wondering if you could do the same for iPhone 3.5 inch screen to iPhone 4 inch screen. I have a game which was originally designed for the iPhone 4 inch screen, but auto layout has been used to fix the errors between the two devices, the one thing I need to change is that when

if (ball.center.y > 600) {
    RandomPosition = arc4random() %248;
    RandomPosition = RandomPosition + 36;
    ball.center = CGPointMake(RandomPosition, -22);
}

Because it was originally designed on the 4 inch screen, the game is set up to reset the ball to the top of the screen when it is > 600 pixels, which is just below the iphone 4 inch screen. It still functions properly, there is just a bit of a delay between the bottom of the 3.5 inch screen and the resetting of the position. Is there anyway I could set up an if statement with UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom(iphone4???) to set up a new ball.center.y > 300 or something?

like image 366
Shen Hutah Avatar asked Feb 27 '14 06:02

Shen Hutah


People also ask

What iPhone has a 4 inch screen?

4 inches: iPhone SE (2016), iPhone 5S (2013), iPhone 5C (2013), iPhone 5 (2012) 4.7 inches: iPhone 8 (2017), iPhone 7 (2016), iPhone 6S (2015), iPhone 6+ (2014), iPhone 6 (2014) 5.4 inches: iPhone 13 Mini (2021), iPhone 12 Mini (2020)

What are the iPhone screen sizes?

iPhone XR, iPhone 12, iPhone 13 Pro and iPhone 13 are the same in terms of screen sizes. All have a 6.1 inch screen. In terms of physical dimensions, the closest in size to the iPhone 11 is the iPhone XR. Both have dimensions of 150.9 x 75.7 x 8.3 mm and resolution of 1792 x 828.

Why were the old iPhones so small?

Tiny screens before iPhone: 2002-2006 At the time, most "smartphones" featured tiny screens, due to the cost and technical issues (including battery life) associated with bigger displays. The size of phone displays was also cramped by the virtual necessity of a physical keypad.


1 Answers

You can try following code. Add this code in Constant.h

#define IS_IPAD (( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) ? YES : NO)
#define IS_IPHONE_5 (([UIScreen mainScreen].scale == 2.f && [UIScreen mainScreen].bounds.size.height == 568)?YES:NO)
#define IS_RETINA_DISPLAY_DEVICE (([UIScreen mainScreen].scale == 2.f)?YES:NO)

Now to check the device size add the following code in your Views

if (IS_IPAD)
{
       //do stuff for iPad
}
else
{
     if(IS_IPHONE_5)
     {
        //do stuff for 4 inch iPhone screen
     }
     else
     {
        //do stuff for 3.5 inch iPhone screen
     }

}
like image 141
Akshay Aher Avatar answered Sep 23 '22 00:09

Akshay Aher