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 ↗Code shown on screen · 4 snippets
PHPicker Example (UIKit)
var configuration = PHPickerConfiguration()
configuration.filter = .images
configuration.selection = .ordered
configuration.selectionLimit = 10
let picker = PHPickerViewController(configuration: configuration) PHPickerFilter
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)
var configuration = PHPickerConfiguration()
configuration.filter = .images
configuration.selectionLimit = 10
let picker = PHPickerViewController(configuration: configuration) PhotosPicker Example (SwiftUI)
struct ContentView: View {
selection: [PhotosPickerItem]
var body: some View {
PhotosPicker(
selection: $selection,
matching: .images
) {
Text("Select Photos")
}
}
} Resources
Related sessions
-
14 min -
10 min -
18 min -
15 min