Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

2022 EssentialsPhotos & Camera

WWDC22 · 15 min · Essentials / Photos & Camera

What’s new in the Photos picker

PHPicker provides simple and secure integration between your app and the system Photos library. Learn how SwiftUI and Transferable can help you offer integration across iOS, iPadOS, macOS, and watchOS. We’ll also show you how you can use AppKit and NSOpenPanel to bring the Photos picker on Mac into your macOS apps. For even more on the Photos picker, watch "Improve access to Photos in your app" from WWDC21.

Watch at developer.apple.com ↗

Transcript all transcripts

Code shown on screen · 4 snippets

PHPicker Example (UIKit) swift · at 0:01 ↗
var configuration = PHPickerConfiguration()
configuration.filter = .images
configuration.selection = .ordered
configuration.selectionLimit = 10

let picker = PHPickerViewController(configuration: configuration)
PHPickerFilter swift · at 0:02 ↗
var configuration = PHPickerConfiguration()

// iOS 15
// Shows videos and Live Photos
configuration.filter = .any(of: [.videos, .livePhotos])

// New: iOS 15
// Shows screenshots only
configuration.filter = .screenshots

// New: iOS 15
// Shows images excluding screenshots
configuration.filter = .all(of: [.images, .not(.screenshots)])

// New: iOS 16
// Shows cinematic videos
configuration.filter = .cinematicVideos
PHPicker Example (AppKit) swift · at 0:03 ↗
var configuration = PHPickerConfiguration()
configuration.filter = .images
configuration.selectionLimit = 10

let picker = PHPickerViewController(configuration: configuration)
PhotosPicker Example (SwiftUI) swift · at 0:04 ↗
struct ContentView: View {
    @Binding selection: [PhotosPickerItem]
    
    var body: some View {
        PhotosPicker(
            selection: $selection,
            matching: .images
        ) {
            Text("Select Photos")
        }
    }
}

Resources