d0ping / DBAttachmentPickerController

This powerful component allows to select different types of files from different sources on your device.
MIT License
254 stars 52 forks source link

DBAttachmentPickerController

Version License Platform Language

This powerful component allows to select different types of files from different sources on your device.

iCloud Documents Capability

Preview

iCloud Documents Capability

Requirements

Adding to your project

Cocoapods

To add DBAttachmentPickerController via CocoaPods into your project:

  1. Add a pod entry for DBAttachmentPickerController to your Podfile pod 'DBAttachmentPickerController', '~> 1.1.0'
  2. Install the pod by running pod install

Source Files

To add DBAttachmentPickerController manually into your project:

  1. Download the latest code, using git clone
  2. Open your project in Xcode, then drag and drop entire contents of the Source folder into your project (Make sure to select Copy items when asked if you extracted the code archive outside of your project)

Usage

To use DBAttachmentPickerController in your project you should perform the following steps:

  1. Initialize Attachment picker controller (see the Constructors section)
  2. Specify additional options if nedded (see the Property list section)
  3. Present Attachment picker controller (see the Presentation section)
- (void)addAttachment {
    // (1)
    DBAttachmentPickerController *attachmentPickerController = [DBAttachmentPickerController attachmentPickerControllerFinishPickingBlock:^(NSArray<DBAttachment *> * _Nonnull attachmentArray) {...} cancelBlock:^{...}];

    // (2)
    attachmentPickerController.mediaType = DBAttachmentMediaTypeImage | DBAttachmentMediaTypeVideo;
    attachmentPickerController.capturedVideoQulity = UIImagePickerControllerQualityTypeHigh;
    attachmentPickerController.allowsMultipleSelection = YES;
    attachmentPickerController.allowsSelectionFromOtherApps = YES;

    // (3)
    [attachmentPickerController presentOnViewController:self];
}

Constructors

To initialize the attachment picker controller you have to call one of the following methods:

Property list

You can change additional Attachment Picker Controller properties. Full properties list is shown below:

Presentation

After creation Attachment Picker Controller you should set additional options if needed (see the Property list section) and present it.

Usage Document Picker (Other apps button)

To usage Document Picker you must:

DBAttachment

The class contain metadata about selected item.

You can use following properties to get metadata of file:

To get thumbnail image you should call folowing method: -loadThumbnailImageWithTargetSize:completion:. Or you can get original image through method -loadOriginalImageWithCompletion:.

Also you can get original file data if call appropriate method -originalFileResource.

Version history

1.1.0

Contact

Denis Bogatyrev (maintainer)

License

DBAttachmentPickerController - Copyright (c) 2016 Denis Bogatyrev

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.