iOS 14+ 照片有限权限场景下UIImagePickerController适配方案问询
Great question—this is a common pain point with iOS 14+'s limited photo permissions, especially when PHPicker lacks the editing tools we rely on. Let's break down the best alternatives to your current "middle page" idea, along with pros and cons for each:
1. Use PHPicker + Custom Editing Tools (Recommended)
First, a key detail you might miss: even in limited permission mode, PHPicker lets users select any photo or video from their library (it’s a system-provided picker that bypasses your app’s direct library access restrictions). Once the user selects a media item, your app gets temporary access to it—perfect for adding your own editing features.
Here’s how to implement this:
- Set up PHPicker: Configure the picker to target photos/videos, then handle the selection callback to retrieve the
PHPickerResult. - Fetch the media: Use
PHPickerResult.itemProviderto load the asset (for images, useloadObject(ofClass: UIImage.self); for videos, useloadFileRepresentation(forTypeIdentifier: UTType.movie.identifier)). - Add custom editing:
- For image cropping: Use
CIImagewith theCICropfilter, or build a simple cropping UI withUIScrollViewandUIBezierPathto let users define a crop area. - For video trimming: Use
AVFoundation—create anAVMutableCompositionto trim the asset to the user’s selected time range, then export it withAVAssetExportSession.
- For image cropping: Use
Example PHPicker setup snippet:
var configuration = PHPickerConfiguration() configuration.filter = .any(of: [.images, .videos]) configuration.selectionLimit = 1 // Adjust based on your needs let picker = PHPickerViewController(configuration: configuration) picker.delegate = self present(picker, animated: true)
This approach is Apple-compliant, gives users full access to their library, and lets you build exactly the editing features you need without relying on UIImagePicker’s buggy behavior in limited mode.
2. Guide Users to Upgrade Permissions (When Editing Is Core)
If your app’s core functionality depends on in-library editing (like cropping/trimming directly in the photo grid), you can gently guide users to upgrade from limited to full access. But you must follow Apple’s strict rules:
- Be transparent: Clearly explain why you need full access (e.g., "To let you crop photos and trim videos directly in your album, we need permission to access all your media").
- Avoid spam: Only show this prompt once, or right after the user tries to use an editing feature that requires full access.
- Provide a direct Settings link: Let users jump to app settings with one tap:
if let settingsURL = URL(string: UIApplication.openSettingsURLString) { UIApplication.shared.open(settingsURL) }
Note: Apple will reject apps that pressure users into granting full permissions, so ensure your app still works (with limited functionality) if the user declines.
3. Optimize Your "Authorized Assets Middle Page" Idea
If you still want to stick with showing only pre-authorized assets, you can refine this approach to be more user-friendly:
- Fetch authorized assets: Use
PHAsset.fetchAssets(with: nil, options: nil)—in limited mode, this will only return assets the user has previously allowed your app to access. - Build a custom picker: Use
PHImageManagerto load thumbnails and full-size media, then integrate your own editing tools directly into this picker. - Add an "Add More Photos" button: Link this button to PHPicker, so users can select new media (which will automatically be added to your app’s authorized list).
The downside here is that users can’t browse their full library without switching to PHPicker, so it’s less intuitive than the first option.
Quick Fix for Your Current Code
In your .limited case, avoid using UIImagePickerController—it’s known to behave unpredictably when the app has only limited access. Replace it with PHPicker instead, and handle editing via custom tools as outlined above.
内容的提问来源于stack exchange,提问作者Jatin Garg

