ImagePickerSheetController replicates the custom photo action sheet in iMessage.

Overview

ImagePickerSheetController

Twitter: @lbrndnr License Carthage compatible

About

ImagePickerSheetController is a component that replicates the custom photo action sheet in iMessage. It's very similar to UIAlertController which makes its usage simple and concise. ⚠️ You can also find an iOS 10 version of this library here ⚠️

Screenshot

Usage

ImagePickerSheetController is similar to UIAlertController in its usage.

Example

let controller = ImagePickerSheetController(mediaType: .ImageAndVideo)
controller.addAction(ImagePickerAction(title: NSLocalizedString("Take Photo Or Video", comment: "Action Title"), secondaryTitle: NSLocalizedString("Add comment", comment: "Action Title"), handler: { _ in
	presentImagePickerController(.Camera)
}, secondaryHandler: { _, numberOfPhotos in
	println("Comment \(numberOfPhotos) photos")
}))
controller.addAction(ImagePickerAction(title: NSLocalizedString("Photo Library", comment: "Action Title"), secondaryTitle: { NSString.localizedStringWithFormat(NSLocalizedString("ImagePickerSheet.button1.Send %lu Photo", comment: "Action Title"), $0) as String}, handler: { _ in
	presentImagePickerController(.PhotoLibrary)
}, secondaryHandler: { _, numberOfPhotos in
	println("Send \(controller.selectedImageAssets)")
}))
controller.addAction(ImagePickerAction(title: NSLocalizedString("Cancel", comment: "Action Title"), style: .Cancel, handler: { _ in
	println("Cancelled")
}))
            
presentViewController(controller, animated: true, completion: nil)

It's recommended to use stringsdict to easily translate plural forms in any language.

Installation

CocoaPods

pod "ImagePickerSheetController", "~> 0.9.1"

###Carthage

github "lbrndnr/ImagePickerSheetController" ~> 0.9.1

You should also add two new values to your app's Info.plist to tell the user why you need to access the Camera and Photo Library.

<key>NSCameraUsageDescription</key>
<string>Camera usage description</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Photo Library usage description</string>

Requirements

ImagePickerSheetController is written in Swift and links against Photos.framework. It therefore requires iOS 9.0 or later.

Author

I'm Laurin Brandner, I'm on Twitter.

License

ImagePickerSheetController is licensed under the MIT License.

Comments
  • Crashing on iphone 5s

    Crashing on iphone 5s

    It works great in the simulator but when ran on my phone it crashes. I'm running ios 8.1.1 on a 5s. To be sure it was not my implementation, I used your code sample to test.

    bug 
    opened by matthewjdrover 11
  • Scrolling not smooth at all on iPhone 5.

    Scrolling not smooth at all on iPhone 5.

    So the problem on my end is that when I tested the example on iPhone 5, iOS 8.3 the scrolling, between the images, was not smooth at all. In iMessage is very smooth.

    Thank you!

    opened by csilouanos 9
  • [Version Supported] 8.0

    [Version Supported] 8.0

    Hey,

    For swift 2.3, it's working but not support pod with 8.0

    [!] Unable to satisfy the following requirements:
    
    - `ImagePickerSheetController (~> 0.9.3)` required by `Podfile`
    
    Specs satisfying the `ImagePickerSheetController (~> 0.9.3)` dependency were found, but they required a higher minimum deployment target.
    

    i'm sad :( Thanks

    opened by gorbat-o 6
  • Get image from slider

    Get image from slider

    When the user takes a photo manually, the didFinishPickingWithOptions (or something really similar) method gets called so you can get the image from there. This also works when manually selecting from Photo Library. The problem I'm encountering it when using the slider to pick an image and click send, I can't get the image file. I can use controller.selectedImageAssets but it's a [phasset] file.

    How am I actually able to get a UIImage from the slider? I'm using the example code.

    Thanks for your help, really like the layout of the custom picker!

    opened by bramroelandts 5
  • Error on integrating IPSC with carthage

    Error on integrating IPSC with carthage

    I'm trying to integrate IPSC with carthage. However the building process of IPSC involves all testing stuffs including Nimble/Quick/KIF and fails eventually when trying to build Quick. I suppose apps link against IPSC should not rely on its unit tests.

    opened by hankbao 5
  • Could not obtain unique identifier for attached screen

    Could not obtain unique identifier for attached screen

    2015-03-16 01:16:38.893 Example[1186:217454] Could not obtain unique identifier for attached screen <UIScreen: 0x1755fd90; bounds = {{0, 0}, {768, 576}}; mode = <UIScreenMode: 0x17662db0; size = 720.000000 x 576.000000; pixel aspect ratio = 1.092593>>

    opened by korovichev 5
  • Add ability to reset selected images

    Add ability to reset selected images

    If an image is already selected when a user taps 'Take Photo', it will skip to the secondary action because the numberOfSelectedImages is already > 0, and the photo is added, rather than presenting the camera UI as expected.

    Note that the example app avoids this scenario, because the 'Take Photo' action is no longer available once a photo is selected.

    This PR adds the ability for an action to reset the selected images, allowing the 'Take Photo' action to work as expected.

    opened by robtimp 3
  • Crashing with iOS 9

    Crashing with iOS 9

    I installed iOS 9 on an iPhone 6 and the library is don't working anymore. Indeed if you tab on any pictures inside the collection view to select one it crashes with the following error :

    2015-06-09 23:05:04.010 barter[592:608643] *** Assertion failure in -[UICollectionViewData validateLayoutInRect:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3473.13/UICollectionViewData.m:408
    2015-06-09 23:05:04.015 barter[592:608643] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'layout attributes for supplementary item at index path (<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}) changed from <UICollectionViewLayoutAttributes: 0x135b39780> index path: (<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}); element kind: (UICollectionElementKindSectionHeader); frame = (73 5; 29 130); hidden = YES; zIndex = 1;  to <UICollectionViewLayoutAttributes: 0x135c32f00> index path: (<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}); element kind: (UICollectionElementKindSectionHeader); frame = (73 5; 29 233); hidden = YES; zIndex = 1;  without invalidating the layout'
    *** First throw call stack:
    
    

    However I fixed the issue in the didSelectItemAtIndexPath method of the library more precisely inside the animateWithDuration block by adding * layout.showsSupplementaryViews = true* between the tableview updates methods.

                    self.setNeedsLayout()
                    UIView.animateWithDuration(enlargementAnimationDuration, animations: {
                        self.tableView.beginUpdates()
                        layout.showsSupplementaryViews = true
                        self.tableView.endUpdates()
                        self.layoutIfNeeded()
                        }, completion: { finished in
                            self.reloadButtonTitles()
                            layout.showsSupplementaryViews = true
                            self.delegate?.imagePickerSheetDidEnlargePreviews?(self)
                    })
    
    

    It is maybe not a real fix because ios9 is under beta. Moreover the fixe appears to make the collectionview scrolling at the beginning so the selected picture will not be at the center of the collection view. But it can still help someone who is facing the same issue.

    opened by grimabe 3
  • Added selection count support

    Added selection count support

    Hello @larcus94,

    ImagePickerSheet is cool. Though it's missing a way of determining how many items can be selected. My application should allow single selection so I added a little code to support that feature.

    Maybe you find it useful as well.

    Regards, Eugene

    opened by mozharovsky 3
  • IOS 10: Photo taken from the camera: Secondary Handler does not get called

    IOS 10: Photo taken from the camera: Secondary Handler does not get called

    I did a bit of debugging and it seems that in the handle() method of ImagePickerAction the numberOfImages variable is zero despite clicking the Use Photo button on the camera.

    If i had more time on hand, I'd probably send a PR but this seems like a trivial fix and the author could probably fix is faster than I could.

    Thanks

    opened by hemantasapkota 2
  • Incompatiable with Xcode 8.0 beta 2

    Incompatiable with Xcode 8.0 beta 2

    Swift sytanx used throughout the project causes compiler issues while running Xcode 8.0 beta 2. Issues range from use of renamed objects (NSPredicate has been renamed to Predicate) to simple syntax changes.

    opened by kimball-j 2
  • First button in actionSheet is animated with scale

    First button in actionSheet is animated with scale

    Branch: fix-maximum-selection IOS: 11

    Currently I faced the problem that the first button in the action-sheet is somehow animated with a scale transition if you present the ImagePickerSheetController which looks really weird.

    This is my code which is from the example code:

    let presentImagePickerController: (UIImagePickerControllerSourceType) -> () = { source in
        let controller = UIImagePickerController()
        controller.delegate = self
        var sourceType = source
        if (!UIImagePickerController.isSourceTypeAvailable(sourceType)) {
            sourceType = .photoLibrary
        }
        controller.sourceType = sourceType
        
        self.present(controller, animated: true, completion: nil)
    }
    
    let controller = ImagePickerSheetController(mediaType: .image)
    controller.maximumSelection = 1
    controller.addAction(ImagePickerAction(title: "Photo Library", secondaryTitle: "Add Selection", handler: { _ in
        presentImagePickerController(.photoLibrary)
    }, secondaryHandler: { _, numberOfPhotos in
    
    }))
    
    controller.addAction(ImagePickerAction(title: "Take Photo", handler: { _ in
        presentImagePickerController(.camera)
    }, secondaryHandler: { _, numberOfPhotos in
        presentImagePickerController(.camera)
    }))
    
    controller.addAction(ImagePickerAction(cancelTitle: "Cancel"))
    
    present(controller, animated: false, completion: nil)
    

    As you can see I set animated to false cause this seems like the only solution for me. Does someone else have the problem or a solution for it?

    opened by Yetispapa 0
  • No animation in

    No animation in

    I present ImagePickerSheetController with animation set to true, but what happens instead is I see perhaps the last frame of an animation in. The background color fades in, but the picker itself basically just appears.

    opened by ProjectDent 1
  • "Add Comment"

    Hello Laurin - great library you have here, thanks for sharing it. Love the animations and general structure of the code (I'm at the tip of the fix-maximum-selection branch). Just had something of a basic question about the intent/purpose of the two ImagePickerAction rows once at least one image has been selected.

    From what I can seem to see, both actions will fire the same handler, though we can have separate titles for them. The example usage refers to "Add Comment" which may well be useful, keeping in mind it would apply to N photos.

    In order of importance to me, I'd love to either:

    1. Hide/remove that first ImagePickerAction if and only if > 0 images have been selected, or
    2. Alter the handler that fires for that first row (so I could pop a modal text field to ask for comments, say). Not sure how I'd know when that happened though, nor can I currently get to the handler: Handler? instance member as it's both fileprivate and a let to boot.

    Thanks in advance for your (or anyone else's) thoughts.

    opened by scottcc 5
  • Cache for every Image instead of  requiring Image In prepareAssets() mehod

    Cache for every Image instead of requiring Image In prepareAssets() mehod

    In Apple's document, " You access the contents of a fetch result with the same methods and conventions used by the NSArray class. Unlike an NSArray object, however, a PHFetchResult object dynamically loads its contents from the Photos library as needed, providing optimal performance even when handling a large number of results" in PHFetchResult. The method to improve performance is require Image in collectionView:CellForItem method

    opened by xxx50236 0
  • Getting the specs to run was a bit tricky!

    Getting the specs to run was a bit tricky!

    @lbrndnr Are you able to get specs to run easily? I had to do a ton of work to get them going.

    1. Looks like you prefer Carthage, which is 💯 but I'm "old school" and still use Pods, so I added KIF and Quick&Nimble via a Podfile. So that involved using a workspace and changing IPSC.xcodeproj/project.pbproj to be compatible
    2. Exposed waitForViewWithAccessibilityIdentifier (and friends) in KIFExtensions.swift. Looks like you used to maintain a fork of KIF, but it's been deleted? These methods are not available in KIF v 3.4.2 (latest)
    3. On the upside, it would be easy to get Travis-CI running, I've used it w/ Pods enough to be able to get that going.

    Thoughts on all this? Feels like I must be doing something wrong...

    opened by colinta 2
Owner
Laurin Brandner
Laurin Brandner
Jogendra 113 Nov 28, 2022
📸 iMessage-like, Image Picker Controller Provides custom features.

RAImagePicker Description RAImagePicker is a protocol-oriented framework that provides custom features from the built-in Image Picker Edit. Overview O

Rashed Al-Lahaseh 14 Aug 18, 2022
Highly customizable Action Sheet Controller with Assets Preview written in Swift

PPAssetsActionController Play with me ▶️ ?? If you want to play with me, just tap here and enjoy! ?? ?? Show me ?? Try me ?? The easiest way to try me

Pavel Pantus 72 Feb 4, 2022
A carousel of stacked items as seen in iMessage for photos

StackedItemsCarousel A carousel of stacked items (such as photos) as seen in iMessage What? iMessage on iOS 15 shows multiple photos in a carousel of

Andreas Verhoeven 5 Sep 30, 2022
A photo gallery for iOS with a modern feature set. Similar features as the Facebook photo browser.

EBPhotoPages ”A photo gallery can become a pretty complex component of an app very quickly. The EBPhotoPages project demonstrates how a developer coul

Eddy Borja 1.7k Dec 8, 2022
React-native-photo-editor - Photo editor using native modules for iOS and Android

?? Image editor using native modules for iOS and Android. Inherit from 2 available libraries, ZLImageEditor (iOS) and PhotoEditor (Android)

Baron Ha. 244 Jan 5, 2023
DGCropImage - A photo cropping tool which mimics Photo.app written by Swift

DGCropImage A photo cropping tool which mimics Photo.app written by Swift. This

donggyu 11 Jul 14, 2022
Photo-Sharing-App - Photo Sharing App With Swift

Photo Sharing App You can register and log in to this application and share your

Yağız Savran 2 Jun 14, 2022
Custom iOS camera and photo picker with editing capabilities

Overview Paparazzo is a component for picking and editing photos. Key Features ?? Taking photos using camera ?? Picking photos from user's photo libra

avito.tech 757 Jan 4, 2023
A library that makes defines your style sheet like a breeze.

Atelier A library that makes defines your style sheet like a breeze. Requirements iOS 13.0+ Xcode 12.0+ Swift 5.3+ Installation You can add Atelier to

Hsieh Min Che 1 Dec 29, 2022
An iOS/tvOS photo gallery viewer, useful for viewing a large (or small!) number of photos.

This project is unmaintained. Alex passed away in an accident in late 2019. His love of iOS development will always be remembered. AXPhotoViewer AXPho

Alex Hill 596 Dec 30, 2022
FacebookImagePicker is Facebook album photo picker written in Swift.

Features • Installation • Usage • Translation • License GBHFacebookImagePicker is Facebook's album photo picker written in Swift, built to provide a s

Florian Gabach 231 Dec 17, 2022
FMPhotoPicker is a modern, simple and zero-dependency photo picker with an elegant and customizable image editor

FMPhotoPicker is a modern, simple and zero-dependency photo picker with an elegant and customizable image editor Quick demo Batch select/deselect Smoo

Cong Nguyen 648 Dec 27, 2022
TripUp is an open source, photo storage and sharing app made for privacy conscious users.

TripUp is an open source, photo storage and sharing app made for privacy conscious users.

TripUp 19 Aug 26, 2022
Lightweight iOS Photo Blur App

Blurry Blurry is the go-to image blurring tool to help you apply beautiful blurs for your photos. It is perfect for creating wallpapers, backgrounds,

Andy 17 Nov 22, 2022
Turn a photo of your food into a face

Megabite Megabite is a mobile app that automatically turns a photo of your food into a face. Read more about it here. Installation This project uses C

Aaron Randall 361 Oct 26, 2022
PixPic, a Photo Editing App

PixPic PixPic, a Photo Editing App Built by Our iOS Interns What's the best way to teach interns how to write an iOS app? Just let them do it! This ap

Yalantis 1.3k Dec 24, 2022
AR相册 Photo Album For AR

HeavenMemoirs - AR相册 线上地址 https://itunes.apple.com/cn/app/weare/id1304227680?mt=8 HeavenMemoirs 技术点 AR初始化 在新建项目时可以直接创建 AR 项目, xcode 会创造一个 AR 项目的模板. 也可

Heikki 677 Dec 6, 2022
This simple cordova plugin will download picture from an URL and save to IOS Photo Gallery.

Photo Viewer This plugin is intended to download a picture from an URL into IOS Photo library.. How to Install Cordova: cordova plugin add https://git

Alwin jose 1 Oct 23, 2021