Skip to content

New version! It's A Facebook style Image Picker Controller by Swift.

License

Notifications You must be signed in to change notification settings

izrie/DKImagePickerController

Repository files navigation

DKImagePickerController

Build Status Version Status license MIT

Update for Xcode 6.4 with Swift 1.2

Description

New version! It's A Facebook style Image Picker Controller by Swift.

Requirements

  • iOS 7.1+
  • ARC

Installation

iOS 8 and newer

DKImagePickerController is available on Cocoapods. Simply add the following line to your podfile:

# For latest release in cocoapods
pod 'DKImagePickerController'

iOS 7.x

To use Swift libraries on apps that support iOS 7, you must manually copy the files into your application project. iOS 7.x

Getting Started

Initialization and presentation

let pickerController = DKImagePickerController()

pickerController.didCancelled = { () in
    println("didCancelled")
}

pickerController.didSelectedAssets = { [unowned self] (assets: [DKAsset]) in
    println("didSelectedAssets")
    println(assets)
}

self.presentViewController(pickerController, animated: true) {}

Customizing

/// The maximum count of assets which the user will be able to select.
public var maxSelectableCount = 999

/// The type of picker interface to be displayed by the controller.
public var assetType = DKImagePickerControllerAssetType.allAssets

/// Whether allows to select photos and videos at the same time.
public var allowMultipleType = true

/// The callback block is executed when user pressed the select button.
public var didSelectedAssets: ((assets: [DKAsset]) -> Void)?

/// The callback block is executed when user pressed the cancel button.
public var didCancelled: (() -> Void)?

/// It will have selected the specific assets.
public var defaultSelectedAssets: [DKAsset]? {
    didSet {
        if let defaultSelectedAssets = self.defaultSelectedAssets {
            for (index, asset) in enumerate(defaultSelectedAssets) {
                if asset.isFromCamera {
                    self.defaultSelectedAssets!.removeAtIndex(index)
                }
            }
            
            self.selectedAssets = defaultSelectedAssets
            self.updateDoneButtonTitle()
        }
    }
}

Localization

It has been supported languages so far:

  • en.lproj
  • zh-Hans.lproj

If you want to add new language, pull request or issue!

Soon to do

  • Simply to take a picture!
  • It can hide the camera.
  • Simple photo browser.

Any pull requests to be welcome!!!

About

New version! It's A Facebook style Image Picker Controller by Swift.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 98.7%
  • Ruby 1.3%