Camera access allows an iOS app to capture photos or videos using the device camera.
Photo Library access allows an app to select and use existing images/videos stored on the device.
👉 In simple words:
A built-in iOS class used to:
To handle results:
UIImagePickerControllerDelegateUINavigationControllerDelegateiOS requires user permission:
import UIKit
if UIImagePickerController.isSourceTypeAvailable(.camera) {
print("Camera available")
}
let picker = UIImagePickerController()
picker.sourceType = .camera
picker.delegate = self
present(picker, animated: true)
let picker = UIImagePickerController()
picker.sourceType = .photoLibrary
picker.delegate = self
present(picker, animated: true)
func imagePickerController(_ picker: UIImagePickerController,
didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let image = info[.originalImage] as? UIImage {
imageView.image = image
}
picker.dismiss(animated: true)
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
picker.dismiss(animated: true)
}
User taps button
↓
UIImagePickerController opens
↓
Camera / Photo Library
↓
User selects or captures image
↓
Delegate returns image
↓
Image displayed in app
Add in Info.plist:
Privacy - Camera Usage Description
We need camera access to take photos.
Privacy - Photo Library Usage Description
We need access to your photos.
Camera → capture new images
Photo Library → select existing images
Uses UIImagePickerController
Requires permissions in Info.plist
Delegate methods handle results
Must test camera on real device
Common in:
Open this section to load past papers