0

I've done this in Android with but can't seem to find any information on doing this in iOS. Basically:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/JPEG");
Intent i = Intent.createChooser(intent, "File");
startActivityForResult(i, CHOOSE_FILE_REQUESTCODE);

Then

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Check which request we're responding to
    if (requestCode == CHOOSE_FILE_REQUESTCODE) {
        // Make sure the request was successful
        if (resultCode == RESULT_OK) {
            // The user picked a contact.
            // The Intent's data Uri identifies which contact was selected.

            // Do something with the contact here (bigger example below)
        }
    }
}

What/where is the corresponding terminology & sample code?

(Objective-C Examples Appreciated)

Enigma
  • 1,247
  • 3
  • 20
  • 51

3 Answers3

1

The UIImagePickerController view controller in iOS is a standard way of allowing the user to choose pictures from there media library. The Apple documentation on this is available at UIImagePickerController. There is also a good tutorial that shows how to use UIImagePickerController at Picking images with UIImagePickerController in Swift 5.

Dean
  • 939
  • 10
  • 30
0

This should exactly what you're looking for: https://stackoverflow.com/a/41717882/2968456

Basically you need to use Apple's built-in UIImagePicker framework.

janakmshah
  • 154
  • 9
0

Credit primarily goes to other answers for reference but here's the Objective-C example code:

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
presentViewController:picker animated:YES completion:nil];

Callback with image data:

/*============================================================================*/

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

/*============================================================================*/
{
    [picker dismissViewControllerAnimated:YES completion:nil];
    [picker release];

    UIImage* image = [info objectForKey:UIImagePickerControllerEditedImage];
    if (!image)
        image = [info objectForKey:UIImagePickerControllerOriginalImage];

    NSData* imgData = UIImageJPEGRepresentation(image, 1.0);
    NSLog(@"Size of Image(bytes):%lu",(unsigned long)[imgData length]);
}

Delegate/self must be:

UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
Enigma
  • 1,247
  • 3
  • 20
  • 51