【问题标题】:IOS/Objective-C/imagePicker: Skip 'Choose' stepIOS/Objective-C/imagePicker:跳过“选择”步骤
【发布时间】:2015-11-24 12:52:03
【问题描述】:

我的 uiimagepicker 控制器方法让用户选择照片,一旦选择,询问用户是否要“选择照片”。

但是,我遇到了另一个跳过此步骤的项目。用户点击照片的那一刻,它被选中,选择器被关闭,我们在原始控制器中看到图像。我更喜欢这个,因为它更快。

谁能解释如何跳过“选择”步骤?

Here is my code:
- (IBAction)selectPhoto:(id)sender {
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = YES;
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    [self presentViewController:picker animated:YES completion:NULL];

}

#pragma mark - Image Picker Controller delegate methods

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
    self.imageView.image = chosenImage;
    self.changedPic=YES;
    [picker dismissViewControllerAnimated:YES completion:NULL];

}

这是跳过该步骤的其他代码:

- (IBAction) pickImage:(id)sender{

    UIImagePickerController *pickerController = [[UIImagePickerController alloc] init];
    pickerController.delegate = self;
    [self presentViewController:pickerController animated:YES completion:nil];
}

#pragma mark -
#pragma mark UIImagePickerControllerDelegate

- (void) imagePickerController:(UIImagePickerController *)picker
         didFinishPickingImage:(UIImage *)image
                   editingInfo:(NSDictionary *)editingInfo
{
    self.imageView.image = image;
    pngData = UIImagePNGRepresentation(image);
    [self dismissModalViewControllerAnimated:YES];
}

我没有立即看出是什么导致了差异,但也许有一些委托方法或可以做到这一点的东西。感谢您的任何建议。

【问题讨论】:

    标签: ios uiimagepickercontroller


    【解决方案1】:

    刚刚设置

     picker.allowsEditing = NO;
    

    动图

    【讨论】:

    • 请注意,如果您在 mediaTypes 属性中包含 kUTTypeLivePhoto,那么即使“allowsEditing”属性设置为 NO,也会出现“选择”步骤。
    【解决方案2】:

    设置picker.allowsEditing = NO;

    【讨论】:

      猜你喜欢
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-20
      相关资源
      最近更新 更多