Introduction to TNKImagePickerController

TNKImagePickerController is a powerful and feature-rich iOS library that allows developers to easily integrate a customized image picker into their applications. With TNKImagePickerController, you can enable users to select images and videos from their device’s gallery, camera roll, or take new photos and videos directly from within your app.

Key Features

  • Flexible Configuration: TNKImagePickerController offers a wide range of customization options. Developers can fine-tune various aspects including selection limit, media types, grid appearance, thumbnail size, and more.
  • Multiple Selection: Users can select multiple images and videos at once, providing a seamless experience for applications that require batch media selection.
  • Camera Integration: TNKImagePickerController allows users to take new photos and videos directly from within the application, without switching to the default camera app.
  • Action and Delegate Methods: The library provides various callback methods and delegate protocols for developers to handle events such as media selection, deselection, and cancellation.
  • Media Types: TNKImagePickerController supports a wide range of media types including images, videos, and Live Photos. Developers can configure the library to allow or restrict certain media types as per their application’s requirements.
  • Localization: The library is localized in multiple languages, making it easier for developers to provide a localized image picker interface to global users.

Installation Guide

To integrate TNKImagePickerController into your iOS project, follow the steps below:

  1. Open your project in Xcode and navigate to the root directory.
  2. Create a new group called “TNKImagePickerController” in Xcode’s project navigator.
  3. Right-click on the newly created group and select “Add Files to [project name]”.
  4. Locate the downloaded TNKImagePickerController library file and add it to the “TNKImagePickerController” group.
  5. In the “Add to targets” section, ensure your project’s target is selected.
  6. Click “Add” to add the library files to your project.

Usage Guide

To use TNKImagePickerController in your application, follow the steps below:

  1. Import the TNKImagePickerController library by adding the following line at the top of your view controller:

import TNKImagePickerController
  1. Create an instance of TNKImagePickerController in your view controller’s code:

let imagePickerController = TNKImagePickerController(maximumSelectionCount: 10)
  1. Customize the image picker by modifying various properties and settings. For example:

imagePickerController.preferredLanguage = "en" // Set the library's language to English
imagePickerController.mediaTypes = [.image] // Allow only image selection
imagePickerController.defaultSelectedAssets = [PHAsset]() // Pre-select specific assets
// ...more customization options...
  1. Present the image picker in your application’s relevant view controller:

present(imagePickerController, animated: true, completion: nil)

Example Code

Below is an example code snippet that demonstrates how to handle the media selection in TNKImagePickerController:

// Implement TNKImagePickerControllerDelegate protocol in your view controller
class MyViewController: UIViewController, TNKImagePickerControllerDelegate {
    // ...

    func imagePickerController(_ picker: TNKImagePickerController, didSelectAssets assets: [PHAsset]) {
        // Handle selected media assets
        for asset in assets {
            // Perform desired operations with each selected media asset
            // e.g. uploading to server, saving to local storage, etc.

    // ... implement other delegate methods as per your requirements ...

    // ...

TNKImagePickerController offers a robust and versatile solution for integrating a customized image picker in iOS applications. With its extensive customization options, multi-selection support, and camera integration, it provides developers with a seamless way to enhance the media selection experience within their apps. For more information, refer to the official TNKImagePickerController documentation and API reference.