使用 iOS 访问相机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/74113/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Access the camera with iOS
提问by Jason Francis
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?
很明显,有些人已经能够弄清楚如何通过 SDK(例如 Spore Origins)访问 iPhone 相机。如何才能做到这一点?
回答by wxs
You need to use the UIImagePickerController
class, basically:
您需要使用UIImagePickerController
该类,基本上:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = pickerDelegate
picker.sourceType = UIImagePickerControllerSourceTypeCamera
The pickerDelegate
object above needs to implement the following method:
pickerDelegate
上面的对象需要实现如下方法:
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
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/uiimagepickercontrollerdelegateand https://developer.apple.com/documentation/uikit/uiimagepickercontrollerinfokeyfor more details)
字典info
将包含分别用UIImagePickerControllerOriginalImage
和键控的原始图像和编辑图像的条目UIImagePickerControllerEditedImage
。(有关更多详细信息,请参阅https://developer.apple.com/documentation/uikit/uiimagepickercontrollerdelegate和https://developer.apple.com/documentation/uikit/uiimagepickercontrollerinfokey)
回答by binshi
Hmmmm.....Ever tried using an OverlayView? With this the camera might look customized but in actuality its just a view above it.
嗯..... 曾经尝试过使用 OverlayView 吗?有了这个,相机可能看起来是定制的,但实际上它只是它上面的一个视图。
If the private API's are directly accessed it might result in the app being rejected by Apple. See if the below link helps.
如果直接访问私有 API,则可能会导致应用程序被 Apple 拒绝。看看下面的链接是否有帮助。