如何在 IOS 7 中拍照后跳过重新拍摄/使用照片选项

18

我在使用IOS 7开发一个应用程序,其中使用相机来捕获图像。但是在捕获图像后,它会显示重新拍摄/使用照片选项。我希望在捕获图像后,直接进入下一个屏幕而不显示默认的重新拍摄/使用照片选项。我在谷歌上搜寻了这个问题,但是没有得到合适的解决方法。请帮助我解决这个问题。

提前感谢。

以下是我在项目中使用的代码片段:

enter image description here

-(void)StartCamera

{

if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])

{  

  UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Error"           message:@"Device has no camera" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];

    [myAlertView show];
}
else
{ 
    picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = NO;
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    [self presentViewController:picker animated:YES completion:NULL];
}
}
2个回答

10

iOS 提供的 stock UIImagePickerControllerSourceTypeCamera 具有这两个按钮。

实现你想要的功能的一种方法是继续使用 UIImagePickerViewController,并将 showsCameraControls 设置为 NO。然后,使用 cameraOverlayView 提供自己的用户界面,用于自定义覆盖视图。

self.picker.showsCameraControls = NO;

self.overlay = [[OverlayViewController alloc] initWithNibName:@"Overlay" bundle:nil];
self.overlay.pickerReference = self.picker;

self.picker.cameraOverlayView = self.overlay.view;
self.picker.delegate = self.overlay;

另一种方法是使用AVFoundation创建自己的相机视图。


很酷!还可以看看这个来自苹果的例子:https://developer.apple.com/library/ios/samplecode/AVCam/Introduction/Intro.html - aksh1t
这里是 AVFoundation 示例代码 https://github.com/lteu/demo_AVFoundation。希望能有所帮助。 - tong

-3
    let picker = UIImagePickerController()
        picker.delegate = self
        picker.allowsEditing = false
        picker.automaticallyAdjustsScrollViewInsets = true
        picker.sourceType = UIImagePickerControllerSourceType.camera

适用于相机和相册。

如果您正在使用任何第三方库进行编辑,它将直接引导您到该库或关闭选择器控制器而不提供预览。


1
将allowEditing设置为NO(false)对于我的相机没有起作用。我仍然可以获得重新拍摄/使用照片控件。 - Chris Prince
@ChrisPrince,我对我的答案进行了一些更改,希望能帮助你解决问题。谢谢! - Paul.V
这个答案是不正确的。按照所示设置选项对iOS呈现的使用/重拍用户界面没有影响。这不是".allowsEditing"选项的作用。 - Bill Patterson

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接