当UIImagePickerController拍照时抓取

时间:2014-07-11 06:21:17

标签: ios iphone ios7 uiimagepickercontroller

我有一个像这样的UIImagePickerController:

    // Start picker code
    UIImagePickerController *photo = [[UIImagePickerController alloc] init];
    photo.delegate = self;
    photo.allowsEditing = NO;
    //photo.showsCameraControls = NO;
    photo.sourceType = UIImagePickerControllerSourceTypeCamera;

    cameraView.frame = photo.cameraOverlayView.frame;
    photo.cameraOverlayView = cameraView;



    // photo.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    //[photo setCameraOverlayView:cameraView];

    [self presentViewController:photo animated:YES completion:nil];

我在文档中看到 - (void)takePicture,但是如何在单击图片时运行代码?

1 个答案:

答案 0 :(得分:0)

通过将self注册为UIImagePickerController的代表,您可以覆盖- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

请参阅:https://developer.apple.com/library/ios/documentation/uikit/reference/UIImagePickerControllerDelegate_Protocol/UIImagePickerControllerDelegate/UIImagePickerControllerDelegate.html#//apple_ref/occ/intf/UIImagePickerControllerDelegate