How to Differentiate Between Iphone4 and iPhone 3

How to differentiate between iphone4 and iphone 3

You could check the scale of the screen.

if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2){
//iPhone 4
}

Differentiate between black and white iPhones?

The serial number on the iPhone gives you all this info, you just need to map the code for colour to the colour itself.

Typical format of the iPhone SN is as follows: AABCCDDDEEF

AA = Factory and Machine ID

B = Year of Manufacturing (9 is 2009/2019, 0 is 2010/2020, 1 is 2011 and so on)

CC = Production Week (01 is week 1 of B, 11 is week 11 of B and so on)

DDD = Unique Identifier

EE = Color (A4=black)

F = size (S=16GB, T=32GB)

More info: http://www.pressbyte.com/640/decode-iphone-hardware-information-serial-number/

How to distinguish between iPhone 4 and iPhone 4s in javascript

I see these three options for you:

1) use a precooked open source script to check this and based on the result you do a redirect. You can use this for example: http://detectmobilebrowsers.com/

2) you implement a javascript which do a checking based on the navigator parameters. See this and a quote code from that SO answer.

function iOSversion() {
if (/iP(hone|od|ad)/.test(navigator.platform)) {
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
}
}

3.) you can use rewrite rules at Apache side to redirect to the proper page based on user-agent. See this.

For all 3 options you have a problem that it is hardly possible to distinguish between iPhone 4 and 4s. See this SO answer.

To mention only if you have to check retina capability you can use this JS too:

var isRetina = window.matchMedia("(-webkit-min-device-pixel-ratio: 2)").matches;

More info what is min-device-pixel-ratio here: link.
Also info on media queries here: link

Image resolution support for iPhone 3G, iPhone 4 and iPhone 5

A couple of issues you need to handle:

  1. a "full screen"/background image/other image that is intended to match the aspect ratio of the screen
  2. images that are screen aspect ratio independent

In the case of #1, you will want to provide the same/similar image with different resolutions. One that fits the 320x480 pixel devices, one for the retina display (640x960 pixel) with @2x, and the third to fit the iPhone 5 display (and possibly separate iPad images if it is a universal app).

Unfortunately, iOS does not provide anything like the @2x naming for iPhone 5 displays. A common convention seems to be including @568h in the filename, but that is NOT automatically used by iOS. The solution is to determine if the display is an iPhone and whether it is the taller display. The following code snippet will allow you to do this:

// Is it an iPhone with the tall screen?
if ([[ UIScreen mainScreen ] bounds ].size.height == 568.))

// use the tall image
image = [UIImage imageNamed:@"myImage@568h.png"

else {

// use 'default' image (will use myimage@2x.png if iPhone retina,
// myImage~ipad.png if iPad, myImage~ipad@2x.png if iPad retina)
image = [UIImage imageNamed:@"myImage.png"
}

For #2, since you probably want the 100px x 100px to show as square on all devices, you are ok providing only the 100px x 100px and a 200px x 200px images, with the latter having the @2x in it filename.



Related Topics



Leave a reply



Submit