Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPad 2 detection

Since I don't have iPad 2, I need to know what it returns when calling [[UIDevice currentDevice] model]. I thought it returns just "iPad" but it seems I'm wrong.

Can somebody let me know?

Thanks

like image 970
Martin Avatar asked Mar 17 '11 10:03

Martin


2 Answers

Check for an iPad with a camera.

BOOL isIPad2 = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad &&
                [UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]);

Note that it is generally better to detect specific features rather than make blanket assumptions based on model/version detection. For instance, if you need a camera, then test for the camera explicitly; if you need to tweak the UI quality based on the amount of RAM available, test for physical RAM; etc. Also note a comment I wrote that highlights the dangers of using model detection.

like image 146
Marcelo Cantos Avatar answered Oct 14 '22 12:10

Marcelo Cantos


Never use the model property for anything else than displaying it for informational purposes or diagnostics output. It is not guaranteed to be preserved and if you rely on it, you unnecessarily cut off new devices as they come.

Lots of iPhone apps could not be used in the compatibility mode of iPad just because they checked the model property and if it wasn't iPhone / iPod they didn't do anything.

like image 41
Tomas Vana Avatar answered Oct 14 '22 14:10

Tomas Vana