UIImagePickerController
multiple image selection
iOS development
Swift programming
app development

How to select Multiple images from UIImagePickerController

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

UIImagePickerController does not support multiple image selection. If you need users to choose more than one photo, the modern iOS answer is PHPickerViewController, which was designed for privacy-aware photo picking and supports multiple selection directly. For older codebases, the main lesson is not how to “hack” UIImagePickerController, but when to replace it with the right API.

Why UIImagePickerController Is the Wrong Tool

UIImagePickerController was built for:

  • taking a photo
  • choosing a single photo or video
  • simple media-picking flows

It does not expose a built-in multiple-selection mode. If your requirement is “select several images from the library,” then the API mismatch is the problem.

Use PHPickerViewController

For modern apps, use PHPickerViewController.

swift
1import UIKit
2import PhotosUI
3
4class ViewController: UIViewController, PHPickerViewControllerDelegate {
5
6    func presentPicker() {
7        var config = PHPickerConfiguration()
8        config.filter = .images
9        config.selectionLimit = 0
10
11        let picker = PHPickerViewController(configuration: config)
12        picker.delegate = self
13        present(picker, animated: true)
14    }
15
16    func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
17        picker.dismiss(animated: true)
18        print("Selected count:", results.count)
19    }
20}

selectionLimit = 0 means unlimited selection. Set it to a positive number if you want a cap.

Loading the Selected Images

The results contain item providers. Load each image asynchronously.

swift
1import UIKit
2import PhotosUI
3
4class ViewController: UIViewController, PHPickerViewControllerDelegate {
5    var images: [UIImage] = []
6
7    func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
8        picker.dismiss(animated: true)
9
10        for result in results {
11            let provider = result.itemProvider
12            if provider.canLoadObject(ofClass: UIImage.self) {
13                provider.loadObject(ofClass: UIImage.self) { [weak self] object, error in
14                    guard let image = object as? UIImage else { return }
15                    DispatchQueue.main.async {
16                        self?.images.append(image)
17                    }
18                }
19            }
20        }
21    }
22}

This is the normal pattern for actually retrieving the chosen assets into your app.

Privacy Advantage

PHPickerViewController is not just more capable. It also has a better privacy story. It lets users select photos without your app needing broad direct photo-library access in the same way older flows often did.

That is one reason it is the recommended replacement rather than just a feature upgrade.

What About Older iOS Versions

If you must support iOS versions before PHPickerViewController, you usually have two realistic options:

  1. use a custom photo-selection UI based on Photos framework APIs
  2. adopt a well-maintained third-party picker built on top of those APIs

Trying to force UIImagePickerController into multiple selection is not the right approach because the underlying API was not designed for it.

UIImagePickerController Still Has a Place

It is still useful when you need:

  • camera capture
  • simple single image selection
  • compatibility with older single-item flows

The point is not that the class is useless. The point is that multiple image selection is not its feature set.

Configuration Options in PHPicker

You can also refine the picker behavior.

swift
var config = PHPickerConfiguration(photoLibrary: .shared())
config.filter = .images
config.selectionLimit = 5

That lets you:

  • restrict to images
  • cap the selection count
  • align the picker behavior with your product needs

Think About Result Handling

Selecting multiple images is only the beginning. A real implementation also needs to think about:

  • memory usage
  • thumbnail generation
  • upload ordering
  • duplicate user selections across sessions

If users can pick many large photos, loading everything at full resolution immediately can create memory pressure. Often you want thumbnails first and full data only when necessary.

Common Pitfalls

The biggest mistake is assuming UIImagePickerController has a hidden multiple-selection setting. It does not. Another is migrating to PHPickerViewController but then forgetting that image loading is asynchronous through item providers. Developers also often ignore memory implications when many images are selected at once. Finally, multiple selection and camera capture are separate use cases; PHPicker is about picking from the library, not replacing every UIImagePickerController scenario.

Summary

  • 'UIImagePickerController does not support multiple image selection.'
  • Use PHPickerViewController for multiple image picking in modern iOS code.
  • Set selectionLimit to control how many images the user may choose.
  • Load selected images asynchronously from item providers.
  • Keep UIImagePickerController for single-item or camera-focused flows, not bulk library selection.

Course illustration
Course illustration

All Rights Reserved.