我想使用的UIImagePickerController接口从OS 3.1,与cameraOverlayView和takePicture,但我显然未能理解它是如何工作的,所以我没有得到我想要的行为。

我想要做的就是打开相机并自动拍照,而不必让用户与拣货机交互或编辑图像。所以我继承的UIImagePickerController(类似于 HTTP的例子:/ /github.com/pmark/Helpful-iPhone-Utilities/tree/master/BTL%20Utilities/ )并关闭所有控件:

- (void)displayModalWithController:(UIViewController*)controller animated:(BOOL)animated {
self.sourceType = UIImagePickerControllerSourceTypeCamera;
self.showsCameraControls = NO;
self.navigationBarHidden = YES;
self.toolbarHidden = YES;
    // Setting the overlay view up programmatically.
ipView = [[ImagePickerView alloc] init];
self.cameraOverlayView = ipView;
[controller presentModalViewController:self animated:NO];
}

在OverlayView的,我已经成功地迫使的UIImagePickerController的takePicture方法火(我知道这一点,因为我的NSLog它,我听到相机拍照的声音)。该OverlayView的显示出来就好了。但是,委托方法didFinishPickingMediaWithInfo:不会被调用,而imagePickerControllerDidCancel不会被调用无论是。

所以,我怎么有两种:一是被调用的委托方法,或者通过重写takePicture方法保存的图片? (我不知道怎么在这里拍摄的照片数据,而谷歌似乎已经让我失望)。我不能帮助,我已经无法理解的UIImagePickerController的胆量是如何工作的感觉,但该文档不是过分热情:

e.g:

“你可以提供一个自定义的叠加图显示自定义的拍照界面,你可以从你的代码发起的照片的拍摄。您的自定义重叠视图可以显示在补充或以相反,所提供的默认控件由图像拾取器接口“。

或从showCameraControls:

“如果此属性设置为NO,并提供自定义的控件,可以驳回影像选择器接口之前拍摄多张图片。” - 我如何关闭该挑选器界面

注:委托正确设置在IB,所以这不是问题。

感谢您的帮助,您可以提供!

有帮助吗?

解决方案

我发现,你只需要调用takePicture之前要等待“足够长的时间”,或者它只是静静地失败。我没有对如何确定“足够长的时间”,将始终工作的最低值一个很好的答案,但如果你设置一个计时器,并等待五秒或10秒,你应该没问题。这将是很好,如果它返回某种类型的“我还没准备好拍照呢,对不起”错误直接从takePicture或通过委托,但据我所知没有。

其他提示

作为更新我自己的问题:原来,我试图太早使用takePicture。当我移动到行动上叠加一个按钮,然后从按钮发送takePicture(一旦选择器进行模态呈现),委托方法解雇,因为他们应该。我不知道是否是我想要的是可以实现的 - 拍摄图像,而无需自动按下该按钮时, - 但如果它是,它可能要通过一段时间后,我试图用它发送takePicture完成

- (无效)imageMethod:(ID)发送方{ imagePickerController = [[ALLOC的UIImagePickerController] INIT]; imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

imagePopover=[[UIPopoverController alloc]initWithContentViewController:imagePickerController];
[imagePopover presentPopoverFromRect:importButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top