代码之家  ›  专栏  ›  技术社区  ›  Stella

iPhone:我的程序可以使用imagepicker API访问摄像头吗?

  •  0
  • Stella  · 技术社区  · 16 年前

    如果我的程序想要有一个功能,需要使用UIImagePicker(UIImagePickerControllerSourceTypeCamera)访问摄像头、拍照并返回应用程序,那么我的程序能否在iPhone上实现这一功能,特别是在非越狱设备上?苹果是否允许此类程序在AppStore中上传? 我在某个地方看到,如果我们创建这样一个程序,苹果不允许这个(从第三方应用程序访问摄像头)。是这样吗?

    谢谢你的建议。

    谢谢

    -普拉巴卡尔。

    1 回复  |  直到 16 年前
        1
  •  1
  •   luvieere    16 年前

    你用 UIImagePickerController 直接:

    UIImagePickerController *thePicker = [[UIImagePickerController alloc] init];
    thePicker.delegate = thePickerDelegate;
    thePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    
    //Here you would present thePicker modally, and release it after this
    //It will be deallocated when you remove it from screen
    [anotherViewController presentModalViewController: thePicker animated:NO];
    [thePicker release];
    

    thePickerDelegate ,实施

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

    这个 image UIImagePickerController 要在拍摄一张照片后消失,您可以在此处触发此操作,并在上面的模式示例中通过调用

    [thePicker dismissModalViewControllerAnimated: NO];