TZImagePickerController Documentation

repository·master·Indexed 27 days ago

https://github.com/banchichen/tzimagepickercontroller

An iOS image picker library extending UIImagePickerController. It supports multiple photo selection, original photo selection, video picking, and photo/video previewing for iOS 10 and above. Features include custom asset filtering via isAssetCanBeDisplayed and isAssetCanBeSelected, and support for iOS 18 in version 3.8.8+.

Tokens
851
Snippets
2
Records
7
Agent score
43%

What's inside TZImagePickerController

  1. Install TZImagePickerController

    master

    You can install TZImagePickerController using CocoaPods, Carthage, or manual installation.

    # CocoaPods
    # Full version with all features
    pod 'TZImagePickerController' 
    
    # Basic version (no location code)
    pod 'TZImagePickerController/Basic' 
    
    # Carthage
    github "banchichen/TZImagePickerController"
  2. Check compatibility and version requirements

    master

    Before integrating, ensure your project meets the following requirements based on the version you choose:

    • Minimum iOS Version: Version 3.0.0 and above requires iOS 8 or later. (Versions prior to 3.0.0 supported iOS 6 and 7).
    • iOS 18 Compatibility: Use version 3.8.8 or higher to ensure openURL works correctly and to avoid issues when the photo library is empty.
    • Privacy Manifests: If your app requires privacy manifest compliance, ensure you are using version 3.8.5 or higher.
  3. Configure info.plist permissions

    master

    Since TZImagePickerController uses the Camera, Location, Microphone, and Photo Library, you must add the following keys to your info.plist file to avoid crashes or permission issues:

    • Privacy - Camera Usage Description
    • Privacy - Location Usage Description
    • Privacy - Location When In Use Usage Description
    • Privacy - Microphone Usage Description
    • Privacy - Photo Library Usage Description
    • Prevent limited photos access alert
  4. Initialize and use TZImagePickerController

    master

    To use the image picker, initialize TZImagePickerController with a maximum image count and a delegate. You can handle the selected photos using a block (callback) or the delegate method.

    TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:9 delegate:self];
    
    // You can get the photos by block, the same as by delegate.
    [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
        // Handle selected photos here
    }];
    
    [self presentViewController:imagePickerVc animated:YES completion:nil];
  5. Filter assets using isAssetCanBeDisplayed and isAssetCanBeSelected

    master

    You can implement custom logic to filter which assets are visible or selectable by overriding these methods in your delegate:

    • isAssetCanBeDisplayed: Determines if an asset should be shown in the picker. This is a synchronous method. Note that performing asynchronous tasks (like checking iCloud status or video size) here will slow down the album loading.
    • isAssetCanBeSelected: Determines if a user can select a specific asset. This is called when the user attempts to select the item.
  6. Review TZImagePickerController release notes

    master

    Review the release history to identify version-specific features, bug fixes, and compatibility updates.

    Key highlights include:

    • iOS 18 Support: Version 3.8.8+ fixes openURL issues and supports iOS 18.
    • Privacy Manifests: Version 3.8.5+ includes privacy manifest files.
    • iOS 14 Support: Version 3.8.1+ allows