tags:

views:

197

answers:

2

I want to make an app that can take a snapshot with the cam for a user photo, if the user has an iPhone. If he has an iPod touch, he may choose an standard avatar, but the app should still work on iPod touch. Is that possible?

Or would apple not allow to differenciate programmatically between "yes, he has an iPhone" and "yes, he has an iPod touch"?

+5  A: 

Absolutely!

When you bring up the image picker you specify where to obtain the image - the camera, previous camera pictures, or just the photo album.

You can detect if these are available by calling isSourceTypeAvailable in UIImagePickerController - e.g. [UIImagePicker isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]

Most apps bring up an alert sheet with buttons for the available options (and cancel) and let the user choose. On an iPod Touch the "Camera" button just won't be there (unless Apple bring out a future touch model with a camera!).

Andrew Grant
A: 

There's some sample code here on how to detect what device your code is running on:

http://iphonedevelopment.blogspot.com/2009/05/device-detection.html

The main function is:

  NSString *model= [[UIDevice currentDevice] model];
John