【问题标题】:How to disable Preview screen when using UIImagePickerController Camera使用 UIImagePickerController 相机时如何禁用预览屏幕
【发布时间】:2014-03-30 02:05:31
【问题描述】:

在 iOS7 中,内置相机应用程序在拍照后不会进入预览屏幕,有什么方法可以让 UIImagePicker 表现得像这样。

UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;

我知道另一种解决方案是使用 AVFoundation 类创建自定义相机,但这超出了我的知识范围,我真的很喜欢默认相机的外观。

更新

所以经过更多研究后,我发现我可以创建自己的快门按钮并将其设置为相机叠加层。这就是我所做的

UIButton *shutter = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[shutter addTarget:self action:@selector(shootPicture) forControlEvents:UIControlEventTouchUpInside];
[shutter setTitle:@"S" forState:UIControlStateNormal];
shutter.frame = CGRectMake(50, 50, 60, 60);

UIView *layoutView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
layoutView.opaque = NO;
layoutView.backgroundColor = [UIColor clearColor];
[layoutView addSubview:shutter];

对于 'shootPicture' 方法

- (void) shootPicture
{
   [picker takePicture];
   [self imagePickerController:self.camCtl didFinishPickingMediaWithInfo:nil];
}

如果我只是让选择器调用“takePicture”,我仍然会得到预览,所以我强制选择器在拍照后立即调用 didFinishPickingMediaWithInfo。结果是我看不到预览屏幕但是我也看不到图片。我知道我在 didFinishPickingMediaWithInfo 中输入了“nil”,因为此时我不知道该输入什么。我也知道它拍的照片在某处的缓存中,但我真的不知道如何得到它。

任何想法将不胜感激 =)

【问题讨论】:

    标签: ios7 camera overlay uiimagepickercontroller preview


    【解决方案1】:

    这个解决方案对我有用:

    self.pickerController.allowsEditing = false
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多