检测设备的摄像头是否可用:
- (BOOL) isCameraAvailable{
return [UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera];
}
UIImagePickerControllerSourceTypeCamera 检测摄像头功能;
UIImagePickerControllerSourceTypePhotoLibrary 检测图片库;
UIImagePickerControllerSourceTypeSavedPhotosAlbum 检测相册功能;
Media types:在拍照时,用来指定是拍静态的图片还是录像.kUTTypeImage 表示静态图片, kUTTypeMovie表示录像.
检查相机示例:
- (BOOL) isFrontCameraAvailable{
return [UIImagePickerController
isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront];
}
- (BOOL) isRearCameraAvailable{
return [UIImagePickerController
isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear];
}
- (BOOL) isFlashAvailableOnFrontCamera{
return [UIImagePickerController isFlashAvailableForCameraDevice:
UIImagePickerControllerCameraDeviceFront];
}- (BOOL) isFlashAvailableOnRearCamera{
return [UIImagePickerController isFlashAvailableForCameraDevice:
UIImagePickerControllerCameraDeviceRear];
}
其中,检测相机时系统会首先检测摄像头,所以不用再首先检测摄像头。
详细参考:http://blog.csdn.net/kingsley_cxz/article/details/9157093