使用 iOS 访问相机 [英] Access the camera with iOS
问题描述
很明显,有些人已经能够弄清楚如何通过 SDK 访问 iPhone 摄像头(例如 Spore Origins).如何做到这一点?
It seems obvious that some people have been able to figure out how to access the iPhone camera through the SDK (Spore Origins, for example). How can this be done?
推荐答案
需要用到UIImagePickerController
类,基本上:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = pickerDelegate
picker.sourceType = UIImagePickerControllerSourceTypeCamera
上面的pickerDelegate
对象需要实现如下方法:
The pickerDelegate
object above needs to implement the following method:
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
字典 info
将包含原始图像和编辑图像的条目,分别以 UIImagePickerControllerOriginalImage
和 UIImagePickerControllerEditedImage
为键.(请参阅 https://developer.apple.com/documentation/uikit/uiimagepickercontrollerdelegate 和https://developer.apple.com/documentation/uikit/uiimagepickercontrollerinfokey 了解更多详情)
The dictionary info
will contain entries for the original, and the edited image, keyed with UIImagePickerControllerOriginalImage
and UIImagePickerControllerEditedImage
respectively. (see https://developer.apple.com/documentation/uikit/uiimagepickercontrollerdelegate and https://developer.apple.com/documentation/uikit/uiimagepickercontrollerinfokey for more details)
这篇关于使用 iOS 访问相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!