使用iPhone SDK访问相机 [英] Access the camera with iPhone SDK

查看:188
本文介绍了使用iPhone SDK访问相机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很明显,有些人已经能够弄清楚如何通过SDK(Spore Origins)访问iPhone摄像头,但我没有找到任何有用的信息。我不想任何人违反他们的NDA,但有谁知道任何现有的(官方)资源,显示如何这样做?感谢。

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), but I haven't been able to find any helpful information. I don't want anyone to violate their NDA, but does anyone know of any existing (official) resources that show how this can be done? Thanks.

推荐答案

您需要使用 UIImagePickerController

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = pickerDelegate
picker.sourceType = UIImagePickerControllerSourceTypeCamera

pickerDelegate 上面的对象需要实现以下方法( EDIT 现在已弃用,请参见下文):

The pickerDelegate object above needs to implement the following method (EDIT This is now deprecated, see below):

- (void)imagePickerController:(UIImagePickerController *)picker
                 didFinishPickingImage:(UIImage *)image
                 editingInfo:(NSDictionary *)editingInfo;

在该方法的正文中,图像对象是来自相机的数据,您的具体应用。

Within the body of that method the image object is the data from the camera which you can then use for your specific application.

EDIT

在iPhone OS 3.0 didFinishPickingImage 已被弃用,因此您需要实现:

In iPhone OS 3.0 didFinishPickingImage is deprecated, so instead you'll need to implement:

- (void)imagePickerController:(UIImagePickerController *)picker
                       didFinishPickingMediaWithInfo:(NSDictionary *)info

code>信息将包含原始条目和编辑的图像,用 UIImagePickerControllerOriginalImage 键UIImagePickerControllerEditedImage 。 (请参见 http://developer.apple。 com / iphone / library / documentation / UIKit / Reference / UIImagePickerControllerDelegate_Protocol / UIImagePickerControllerDelegate / UIImagePickerControllerDelegate.html 了解详情)

The dictionary info will contain entries for the original, and the edited image, keyed with UIImagePickerControllerOriginalImage and UIImagePickerControllerEditedImage respectively. (see http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIImagePickerControllerDelegate_Protocol/UIImagePickerControllerDelegate/UIImagePickerControllerDelegate.html for more details)

这篇关于使用iPhone SDK访问相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆