简体   繁体   中英

is it possible to create an app that offers an cam-function on iPhone, but still works on iPod touch without cam-function?

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"?

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 - eg [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.).

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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM