iPhone等:如何判断设备是否有摄像头?

Jim*_*ler 9 iphone

版本3.1.3如果相关.

有这个建议现在可以运作,但将来呢?

NSString *device = [UIDevice currentDevice].model;

if([device isEqualToString:@"iPhone"])
Run Code Online (Sandbox Code Playgroud)

Tom*_*len 39

#define SOURCETYPE UIImagePickerControllerSourceTypeCamera

// does the device have a camera?
if ([UIImagePickerController isSourceTypeAvailable:SOURCETYPE]) {
  // if so, does that camera support video?
  NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:SOURCETYPE];
  bool isA3GS = [mediaTypes containsObject:(NSString*)kUTTypeMovie];
}
Run Code Online (Sandbox Code Playgroud)