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.

Issues
  • 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
  • Add limit var to ImagePickerSheetController

    Add limit var to ImagePickerSheetController

    Limit of selected images, if limit = 1 (previous will be unselected), if limit > 1 = you can't select new images.

    opened by XBeg9 9
  • 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
  • Error selecting image.

    Error selecting image.

    Why when I select the picture select button does not work properly? 2015-07-07 18 24 45

    opened by axenovV 8
  • Obj-C

    Obj-C

    Hello and thanks for this lib. :) Is there any change this can be ported to Obj-C?

    thanks

    opened by mythodeia 7
  • Using this with Objective C

    Using this with Objective C

    Hello,

    I was wondering how can I integrate this with my current objective c code?

    Best, Bennett

    question 
    opened by bennettl 6
  • [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
  • 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
  • KIF tests

    KIF tests

    In order to test the component thoroughly, KIF tests need to be written. Help would be appreciated :)

    enhancement help wanted 
    opened by lbrndnr 5
  • 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
  • Background view wrong frame when inside popover

    Background view wrong frame when inside popover

    When I use the sheet inside a popover, the background view has a wrong frame. Looking into viewDidLayoutSubviews, the view of the ImagePickerSheetController is in fact wrong (as is the enclosing popoverView). To fix this I added two lines of code inside viewDidLayoutSubviews: ... let sheetSize = CGSize(width: view.bounds.width, height: sheetHeight)

        if let _ = popoverPresentationController {
          backgroundView.frame = CGRect(origin: .zero, size: sheetSize)
        }
    

    ...

    opened by fruitcoder 1
  • Choppy scrolling

    Choppy scrolling

    Scrolling in the picker's collection view is very choppy.

    opened by mitchellporter 3
  • Fix iPad design

    Fix iPad design

    bug 
    opened by lbrndnr 1
  • Investigate and improve accessibility

    Investigate and improve accessibility

    • [x] Investigate accessibility for images
    enhancement help wanted 
    opened by lbrndnr 1
Jogendra 101 Dec 29, 2021
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 71 Aug 7, 2021
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 Nov 2, 2021
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 734 Dec 19, 2021
A modern photo viewing experience for iOS.

NYTPhotoViewer NYTPhotoViewer is a slideshow and image viewer that includes double-tap to zoom, captions, support for multiple images, interactive fli

The New York Times 2.8k Jan 3, 2022
Photo Browser / Viewer inspired by Facebook's and Tweetbot's with ARC support, swipe-to-dismiss, image progress and more

IDMPhotoBrowser IDMPhotoBrowser is a new implementation based on MWPhotoBrowser. We've added both user experience and technical features inspired by F

Thiago Peres 2.7k Dec 21, 2021
An image cropper / photo cropper for iOS like in the Contacts app with support for landscape orientation.

RSKImageCropper An image cropper for iOS like in the Contacts app with support for landscape orientation. Installation RSKImageCropper requires iOS 9.

Ruslan Skorb 2.4k Dec 28, 2021
iOS photo gallery written in Swift

SwiftPhotoGallery Overview A full screen photo gallery for iOS and tvOS written in Swift. Photos can be panned and zoomed (iOS only) Pinch to zoom (iO

Justin Vallely 247 Dec 28, 2021
A simple iOS photo and video browser with grid view, captions and selections.

MWPhotoBrowser A simple iOS photo and video browser with optional grid view, captions and selections. MWPhotoBrowser can display one or more images or

Michael Waterfall 8.8k Jan 7, 2022
Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift

SKPhotoBrowser Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift features Display one or more images by providi

keishi suzuki 2.3k Dec 27, 2021
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 223 Jan 4, 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 568 Dec 25, 2021
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 358 Jun 3, 2021
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 Jan 2, 2022
AR相册 Photo Album For AR

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

Heikki 648 Dec 10, 2021
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 560 Jan 4, 2022
Elegant photo browser in Swift. 图片与视频浏览器。

Elegant photo browser in Swift. 图片与视频浏览器。

JiongXing 1.1k Jan 7, 2022
A custom image view that implements device motion scrolling

YXTMotionView A custom image view that implements device motion scrolling Installation CocoaPods Add the dependency to your Podfile: platform :ios pod

Hanton Yang 78 May 19, 2021
A custom ImageView that is used to cover the surface of other view like a scratch card, user can swipe the mulch to see the view below.

MCScratchImageView GIF Showcase Requirments iOS 8.0+ Xcode 7.2+ Swift 4.0 Installation CocoaPods pod "MCScratchImageView" Manually Just drag MCScratch

Jaylen Bian 353 Dec 23, 2021