Giter Site home page Giter Site logo

mohsinalimat / imagepickersheet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lbrndnr/imagepickersheetcontroller

1.0 2.0 0.0 11.45 MB

A duplicate of that shiny new custom action sheet seen in iOS8's iMessage

Home Page: http://laurinbrandner.ch

License: MIT License

Ruby 13.78% Swift 84.92% C++ 1.30%

imagepickersheet's Introduction

ImagePickerSheet

About

ImagePickerSheet is a duplicate of that shiny new custom action sheet seen in iOS8's iMessage that Apple didn't make part of UIKit. It's the first project I've written in Swift. It works well but I might have coded something the Objective-C kind of way. Don't hesitate to open an issue or pull request if you spotted something. And no, ImagePickerSheet does not have the glitches Apple's image picker has :)

demo

Twitter: @larcus94 License Carthage compatible

Author

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

Usage

ImagePickerSheet's API is similar to the one of UIActionSheet so you should get along with it just well.

Example

let sheet = ImagePickerSheet()
sheet.numberOfButtons = 3
sheet.delegate = self
sheet.showInView(view)
func imagePickerSheet(imagePickerSheet: ImagePickerSheet, titleForButtonAtIndex buttonIndex: Int) -> String {
	let photosSelected = (imagePickerSheet.numberOfSelectedPhotos > 0)
        
	if (buttonIndex == 0) {
        if photosSelected {
			return NSLocalizedString("Add comment", comment: "Add comment")
        }
		else {
			return NSLocalizedString("Take Photo Or Video", comment: "Take Photo Or Video")
		}
	}
	else {
		if photosSelected {
			return NSString.localizedStringWithFormat(NSLocalizedString("ImagePickerSheet.button1.Send %lu Photo", comment: "The secondary title of the image picker sheet to send the photos"), imagePickerSheet.numberOfSelectedPhotos) as String
		}
		else {
			return NSLocalizedString("Photo Library", comment: "Photo Library")
		}
	}
}

func imagePickerSheet(imagePickerSheet: ImagePickerSheet, willDismissWithButtonIndex buttonIndex: Int) {
    if buttonIndex != imagePickerSheet.cancelButtonIndex {
        if imagePickerSheet.selectedPhotos.count > 0 {
                println(imagePickerSheet.selectedPhotos)
        }
        else {
            let controller = UIImagePickerController()
            controller.delegate = self
            controller.sourceType = (buttonIndex == 2) ? .PhotoLibrary : .Camera
            presentViewController(controller, animated: true, completion: nil)
        }
    }
}

ImagePickerSheet uses a delegate method, similar to UITableView's dataSource, to get the title of a button. In conjunction with stringsdict, this allows for easy translation of various plural forms.

Installation

CocoaPods

pod "ImagePickerSheet", "~> 0.0.8"

###Carthage

github "larcus94/ImagePickerSheet" ~> 0.0.8

Requirements

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

License

ImagePickerSheet is licensed under the MIT License.

imagepickersheet's People

Contributors

lbrndnr avatar vinnyt avatar retval avatar

Stargazers

MohsinAli avatar

Watchers

MohsinAli avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.