iPhone等:如何判断设备是否有相机?

9

如果相关,版本为3.1.3。

有一个建议,可能现在可行,但将来呢?

NSString *device = [UIDevice currentDevice].model;

if([device isEqualToString:@"iPhone"])
1个回答

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

我在尝试使用这种技术时遇到了问题。这是我收到的错误信息:passing argument 1 of 'containsObject:' from incompatible pointer type 我知道它是CFConstStringRef,但我以前从未使用过...我错过了什么? - Kyle Humfeld
1
Kyle,应该这样写:bool isA3GS = [mediaTypes containsObject:(NSString *)kUTTypeMovie] - Cristian Donoso
1
不要忘记导入 <MobileCoreServices/MobileCoreServices.h>。 - Jasper

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接