【问题标题】:How to force camera to take squared pictures in iOS 7如何在 iOS 7 中强制相机拍摄方形照片
【发布时间】:2013-09-25 11:34:07
【问题描述】:

在 iOS 7 中,相机具有多种模式:视频、照片、方形和全景。在我正在开发的应用程序中,我们允许用户使用相机拍照。我们只想要正方形的图片,所以我们让用户在之后裁剪图片。

是否可以以编程方式强制相机仅拍摄方形照片?

这是我打开相机的代码:

-(void) openImagePickerSource:(UIImagePickerControllerSourceType)type
{
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.delegate = self;
    imagePicker.sourceType = type;
    [self presentViewController:imagePicker animated:YES completion:^{}];
}

我一直在查看文档,但没有找到任何东西。

【问题讨论】:

    标签: iphone ios objective-c camera ios7


    【解决方案1】:

    UIImagePickerController 有一个名为“allowsEditing”的属性。这将全屏打开相机,并允许您在拍摄后调整所拍照片的大小。

    imagePicker.allowsEditing = YES;
    imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
    

    您可以使用“UIImagePickerControllerEditedImage”键在协议方法中获取照片。

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
        UIImage *pic = (UIImage *)[info objectForKey:UIImagePickerControllerEditedImage];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-13
      • 2011-04-10
      • 1970-01-01
      • 1970-01-01
      • 2019-03-19
      • 1970-01-01
      相关资源
      最近更新 更多