• This repository has been archived on 06/Apr/2020
  • Stars
    star
    1,777
  • Rank 26,192 (Top 0.6 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 12 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A clone of UIImagePickerController with multiple selection support.

QBImagePicker

Carthage compatible

A clone of UIImagePickerController with multiple selection support.

screenshot01.png screenshot02.png

Features

  • Allows multiple selection of photos and videos
  • Fast and memory-efficient scrolling
  • Provides similar user interface to the built-in image picker
  • Customizable (grid size, navigation message, etc.)
  • Supports both portrait mode and landscape mode
  • Compatible with iPhone 6/6Plus, and iPad

Requirements

  • Version >= 3.0.0 : iOS 8 or later (Using PhotoKit)
  • Version < 3.0.0 : iOS 6 or later (Using AssetsLibrary)

Example

QBImagePickerController *imagePickerController = [QBImagePickerController new];
imagePickerController.delegate = self;
imagePickerController.allowsMultipleSelection = YES;
imagePickerController.maximumNumberOfSelection = 6;
imagePickerController.showsNumberOfSelectedAssets = YES;

[self presentViewController:imagePickerController animated:YES completion:NULL];

Installation

CocoaPods

  1. Add pod "QBImagePickerController" to Podfile
  2. Run pod install
  3. Add #import <QBImagePickerController/QBImagePickerController.h> to your code

Carthage

  1. Add github "questbeat/QBImagePicker" to Cartfile
  2. Run carthage update
  3. Add #import <QBImagePicker/QBImagePicker.h> to your code

Usage

Basic

  1. Implement QBImagePickerControllerDelegate methods

  2. Create QBImagePickerController object

  3. Set self to the delegate property

  4. Show the picker by using presentViewController:animated:completion:

    QBImagePickerController *imagePickerController = [QBImagePickerController new]; imagePickerController.delegate = self;

    [self presentViewController:imagePickerController animated:YES completion:NULL];

Delegate Methods

Getting the selected assets

Implement qb_imagePickerController:didFinishPickingAssets: to get the assets selected by the user.
This method will be called when the user finishes picking assets.

- (void)qb_imagePickerController:(QBImagePickerController *)imagePickerController didFinishPickingAssets:(NSArray *)assets {
    for (PHAsset *asset in assets) {
        // Do something with the asset
    }

    [self dismissViewControllerAnimated:YES completion:NULL];
}

Getting notified when the user cancels

Implement qb_imagePickerControllerDidCancel: to get notified when the user hits "Cancel" button.

- (void)qb_imagePickerControllerDidCancel:(QBImagePickerController *)imagePickerController {
    [self dismissViewControllerAnimated:YES completion:NULL];
}

Getting notified when the selection is changed

You can handle the change of user's selection by implementing these methods.

- (BOOL)qb_imagePickerController:(QBImagePickerController *)imagePickerController shouldSelectAsset:(PHAsset *)asset;
- (void)qb_imagePickerController:(QBImagePickerController *)imagePickerController didSelectAsset:(PHAsset *)asset;
- (void)qb_imagePickerController:(QBImagePickerController *)imagePickerController didDeselectAsset:(PHAsset *)asset;

Customization

Selection mode

When allowsMultipleSelection is YES, the user can select multiple photos.
The default value is NO.

imagePickerController.allowsMultipleSelection = YES;

You can limit the number of selection by using minimumNumberOfSelection and maximumNumberOfSelection property.
The default value is 0, which means the number of selection is unlimited.

imagePickerController.minimumNumberOfSelection = 3;
imagePickerController.maximumNumberOfSelection = 6;

Specify the albums to be shown

Use assetCollectionSubtypes property to specify the albums to be shown.
The code below shows the default value.

imagePickerController.assetCollectionSubtypes = @[
    @(PHAssetCollectionSubtypeSmartAlbumUserLibrary), // Camera Roll
    @(PHAssetCollectionSubtypeAlbumMyPhotoStream), // My Photo Stream
    @(PHAssetCollectionSubtypeSmartAlbumPanoramas), // Panoramas
    @(PHAssetCollectionSubtypeSmartAlbumVideos), // Videos
    @(PHAssetCollectionSubtypeSmartAlbumBursts) // Bursts
];

The albums will be ordered as you specified.
User's albums are always shown after the smart albums.

Specify the media type to be shown

Use mediaType to filter the assets to be shown.
The default value is QBImagePickerMediaTypeAny.

imagePickerController.mediaType = QBImagePickerMediaTypeVideo;

Showing information

There are some properties to show helpful information.

imagePickerController.prompt = @"Select the photos you want to upload!";
imagePickerController.showsNumberOfSelectedAssets = YES;

Grid size

Use numberOfColumnsInPortrait and numberOfColumnsInLandscape to change the grid size.
The code below shows the default value.

imagePickerController.numberOfColumnsInPortrait = 4;
imagePickerController.numberOfColumnsInLandscape = 7;

License

Copyright (c) 2015 Katsuma Tanaka

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.

More Repositories

1

QBPopupMenu

Customizable popup menu for iOS.
Objective-C
1,382
star
2

Lin

Xcode plugin that provides auto-completion for NSLocalizedString.
Objective-C
1,225
star
3

Lin-Xcode5

A Localization Manager for Xcode 5
Objective-C
968
star
4

QBFlatButton

Flat-Style Button
Objective-C
266
star
5

PopHub-Electron

GitHub activity & notification viewer. Made with Electron.
JavaScript
58
star
6

QBRefreshControl

An abstract base class for creating a refresh control.
Objective-C
56
star
7

QBAnimationSequence

UIView Animation Sequencer
Objective-C
51
star
8

CacheKit

LRU on-memory/disk cache for Swift
Swift
34
star
9

QBValidator

A library for validating values easily.
Objective-C
28
star
10

QBTitleView

Title label and image view for 'titleView' property of UINavigationItem
Objective-C
15
star
11

SlideMenu

View controller container which provides the sliding menus.
Swift
10
star
12

Categories

Objective-C Categories
Objective-C
9
star
13

QBStatusItemView

Custom status item view that can be highlighted programmatically.
Objective-C
9
star
14

PageMenu

View controller container which provides the paged views with menus.
Swift
8
star
15

LiveTeX

PDF Previewer for TeX writing.
Swift
6
star
16

GitHubStatus

A today widget that displays GitHub Service Status
Swift
5
star
17

LaunchAtLoginExample

Code examples of launch at login implementation.
Objective-C
5
star
18

scrapboard

Sticky Notes for Scrapbox
TypeScript
5
star
19

MilkCocoa

A better way to drink Cocoa.
Objective-C
4
star
20

UICollectionViewTrackingDisplayDelegate

UICollectionView+willDisplayCell
Objective-C
4
star
21

XcodeCrasher

Kill Xcode
Objective-C
4
star
22

QBTokenField

Objective-C
4
star
23

kdtree

kdtree module for C++
C++
4
star
24

dotfiles

dotfiles
Shell
4
star
25

LINEActivity

UIActivity subclass for sharing text, URL and image via LINE.
Objective-C
3
star
26

QBSpringButton

UIButton subclass with attractive bounce animation.
Objective-C
3
star
27

anchor

Tab switcher for Google Chrome.
TypeScript
3
star
28

PlugInSample

Objective-C
3
star
29

XcodeBuildSound

Xcode plug-in that plays a random sound when you have a compile error.
Objective-C
3
star
30

CrashReporter

Tweet when Xcode died
Swift
2
star
31

QBRateLimit

Rate limit controller.
Objective-C
2
star
32

capistrano-mackerel

Mackerel integration for Capistrano v3.
Ruby
2
star
33

QBUserDefaults

Objective-C
2
star
34

QBFeedback

QBFeedback is the library for getting feedbacks from the users easily.
Objective-C
2
star
35

PopHubSupport

PopHub issue tracker.
2
star
36

ConvertMovToMpeg

Objective-C
1
star
37

PocketActivity

UIActivity subclass for saving URL to Pocket.
Objective-C
1
star
38

XcodeBackgroundImage

Display a image behind the source text view in Xcode.
Objective-C
1
star
39

ShortMenu

Xcode plug-in which shortens menu titles.
Swift
1
star
40

RateLimit

A rate limit controller for preventing excessive actions.
Swift
1
star
41

KVCCollectionOperatorsExample

Code examples of KVC Collection Operators
Objective-C
1
star