简体   繁体   中英

IOS/Objective-C/imagePicker: Skip 'Choose' step

my method for the uiimagepicker controller lets user select photo and once, selected, asks the user if the user wants to 'Choose Photo'.

However, I came across another project that skips this step. The moment, the user clicks the photo, it is selected, the picker is dismissed and we see the image in the original controller. I like this better cause it's faster.

Can anyone explain how to skip the 'Choose' step?

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];

}

Here is the other code that skips the step:

- (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];
}

I don't immediately see what could account for difference but maybe there is some delegate method or something that does this. Thanks for any suggestions.

Just set

 picker.allowsEditing = NO;

Gif

在此处输入图片说明

设置picker.allowsEditing = NO;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM