-3

I am trying to place an ad, while it looks perfect in the iPhone 5/5s it looks bad in the 4/4s.

Is there a way in my method to tell

if device == iphone4/4s 
    do this
if device == iphone5/5s 
    do that?

Thank you.

Maverick
  • 319
  • 2
  • 13
user3396301
  • 101
  • 1
  • 3
  • 8

3 Answers3

3

Don't do separate code for iPhone4 and iPhone 5 use AutoLayout/ Auto resize.

AutoLayout Introduction

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/AutolayoutPG/AutoLayoutinCode/AutoLayoutinCode.html

Vineesh TP
  • 7,755
  • 12
  • 66
  • 130
2

You can find the device based on the screen size. get device screen size

CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
if(screenHeight > 480)
{
//iphone 5
}
else
{
//iphone 4or 4s or 3 or 3s
}

Note : Window size(including status bar)
iPhone 4S (and earlier) -320 x 480 pts
iPhone 5 -320 x 568 pts

karthikPrabhu Alagu
  • 3,371
  • 1
  • 21
  • 25
1

Check the screen bounds

if ([UIScreen mainScreen].bounds.size.height == 568)
{
    //change the frame of the ad here
}
else
{
    //change the frame of the ad here
}

or use autolayout in your interface file

Rose
  • 437
  • 2
  • 9