Easily take a photo or video or choose from library

Overview

FDTake

CI Status Version License Platform Readme Score

Easily take a photo or video or choose from library

🍺 Author's tip jar: https://amazon.com/hz/wishlist/ls/EE78A23EEGQB

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

To use it in your project, add an FDTakeController to your view controller and implement:

fdTakeController.didGetPhoto = {
    (_ photo: UIImage, _ info: [AnyHashable : Any]) in
}

then call:

fdTakeController.present()

The full API is:

/// Public initializer
public override init()

/// Convenience method for getting a photo
open class func getPhotoWithCallback(getPhotoWithCallback callback: @escaping (_ photo: UIImage, _ info: [AnyHashable : Any]) -> Void) -> <<error type>>

/// Convenience method for getting a video
open class func getVideoWithCallback(getVideoWithCallback callback: @escaping (_ video: URL, _ info: [AnyHashable : Any]) -> Void)

/// Whether to allow selecting a photo
open var allowsPhoto: Bool

/// Whether to allow selecting a video
open var allowsVideo: Bool

/// Whether to allow capturing a photo/video with the camera
open var allowsTake: Bool

/// Whether to allow selecting existing media
open var allowsSelectFromLibrary: Bool

/// Whether to allow editing the media after capturing/selection
open var allowsEditing: Bool

/// Whether to use full screen camera preview on the iPad
open var iPadUsesFullScreenCamera: Bool

/// Enable selfie mode by default
open var defaultsToFrontCamera: Bool

/// The UIBarButtonItem to present from (may be replaced by overloaded methods)
open var presentingBarButtonItem: UIBarButtonItem?

/// The UIView to present from (may be replaced by overloaded methods)
open var presentingView: UIView?

/// The UIRect to present from (may be replaced by overloaded methods)
open var presentingRect: CGRect?

/// The UITabBar to present from (may be replaced by overloaded methods)
open var presentingTabBar: UITabBar?

/// The UIViewController to present from (may be replaced by overloaded methods)
open lazy var presentingViewController: UIViewController { get set }

/// A photo was selected
open var didGetPhoto: ((_ photo: UIImage, _ info: [AnyHashable : Any]) -> Void)?

/// A video was selected
open var didGetVideo: ((_ video: URL, _ info: [AnyHashable : Any]) -> Void)?

/// The user did not attempt to select a photo
open var didDeny: (() -> Void)?

/// The user started selecting a photo or took a photo and then hit cancel
open var didCancel: (() -> Void)?

/// A photo or video was selected but the ImagePicker had NIL for EditedImage and OriginalImage
open var didFail: (() -> Void)?

/// Custom UI text (skips localization)
open var cancelText: String?

/// Custom UI text (skips localization)
open var chooseFromLibraryText: String?

/// Custom UI text (skips localization)
open var chooseFromPhotoRollText: String?

/// Custom UI text (skips localization)
open var noSourcesText: String?

/// Custom UI text (skips localization)
open var takePhotoText: String?

/// Custom UI text (skips localization)
open var takeVideoText: String?

/// Presents the user with an option to take a photo or choose a photo from the library
open func present()

/// Dismisses the displayed view. Especially handy if the sheet is displayed while suspending the app,
open func dismiss()

Other available options are documented at CocoaDocs for FDTake.

How it works

  1. See if device has camera
  2. Create action sheet with appropriate options ("Take Photo" or "Choose from Library"), as available
  3. Localize "Take Photo" and "Choose from Library" into user's language
  4. Wait for response
  5. Bring up image picker with selected image picking method
  6. Default to selfie mode if so configured
  7. Get response, extract image from a dictionary
  8. Dismiss picker, send image to delegate

Support

  • Supports iPhones, iPods, iPads and tvOS (but not tested)
  • Supported languages:
    • English
    • Chinese Simplified
    • Turkish (thanks Suleyman Melikoglu)
    • French (thanks Guillaume Algis)
    • Dutch (thanks Mathijs Kadijk)
    • Chinese Traditional (thanks Qing Ao)
    • German (thanks Lars Häuser)
    • Russian (thanks Alexander Zubkov)
    • Norwegian (thanks Sindre Sorhus)
    • Arabic (thanks HadiIOS)
    • Polish (thanks Jacek Kwiecień)
    • Spanish (thanks David Jorge)
    • Hebrew (thanks Asaf Siman-Tov)
    • Danish (thanks kaspernissen)
    • Sweedish (thanks Paul Peelen)
    • Portugese (thanks Natan Rolnik)
    • Greek (thanks Konstantinos)
    • Italian (thanks Giuseppe Filograno)
    • Hungarian (thanks Andras Kadar)
    • Please help translate FDTake.strings to more languages
  • Pure Swift support and iOS 8+ required
  • Compile testing running on Travis CI
  • In progress: functional test cases (please help)
  • In progress: UI test cases (please help)

Installation

Add this to your project using Swift Package Manager. In Xcode that is simply: File > Swift Packages > Add Package Dependency... and you're done. Alternative installation options are shown below for legacy projects.

CocoaPods

If you are already using CocoaPods, just add 'FDTake' to your Podfile then run pod install.

Carthage

If you are already using Carthage, just add to your Cartfile:

github "fulldecent/FDTake"

Then run carthage update to build the framework and drag the built FDTake.framework into your Xcode project.

Author

William Entriken, [email protected]

Project scope

This is a mature project and we do not expect to add new features unless something has already become state-of-the-art in other applications. Please be prepared to cite screenshots of other apps before making a feature request.

We support targets for the latest released versions of Xcode, Carthage, CocoaPods and Swift Package Manager. If there are incompatabilities, for example CocoaPods not supporting the latest version of Xcode, then we will only support the latest released versions/combinations that are supported. If you would like to support pre-release versions of these packages, please open a pull request, not an issue.

License

FDTake is available under the MIT license. See the LICENSE file for more info.

Contributing

This project's layout is based on https://github.com/fulldecent/swift4-module-template If you would like to change the layout, please change that project FIRST. Also you may appreciate that project has "recipes" -- you don't just change the code, you explain why you are doing things. As a maintainer this makes my job MUCH simpler. In a similar respect, if you are introducing non-minor changes, it will be VERY helpful if you could please reference to another project (like AlamoFire) that has seen and discussed the types of design challenges you are touching.) Thanks again and we all really do appreciate your contributions.

Comments
  • xCode 10 multiple command produce

    xCode 10 multiple command produce

    Hello, I'm having this issue with the new xcode.

    ` Showing All Messages -1: Multiple commands produce 'Products/Dev-iphonesimulator/FDTake/FDTake.framework/Info.plist':

    1. Target 'FDTake' (project 'Pods') has copy command from '.../FDTake/Source/Info.plist' to '/.../Build/Products/Dev-iphonesimulator/FDTake/FDTake.framework/Info.plist'
    2. Target 'FDTake' (project 'Pods') has process command with output '/...Build/Products/Dev-iphonesimulator/FDTake/FDTake.framework/Info.plist' `

    It's doubling plist files. THe issue can be resolved by deleting corresponding plist from the pod target. But with each pod install or xcode launch it switches back to previous state. Could you please take a look?

    opened by havebeenfitz 18
  • whose view is not in the window hierarchy

    whose view is not in the window hierarchy

    After calling FDTake from a Modalview, It fires me:

    <UIImagePickerController: 0x979d4b0> on <CustomTabBarControllerViewController: 0xb64ee60> whose view is not in the window hierarchy!

    Where CustomTabBarControllerViewController is the rootview. The modal should fire the imagepicker, not the rootview, don't it?

    invalid 
    opened by denadai2 13
  • New project structure to solve localization problems

    New project structure to solve localization problems

    The code for localization works well. To solve the issue #100 I have modified the project structure:

    • removing the FDTake.xcworkspace file
    • creating a new Podfile for the 'iOS Example'
    • running the 'pod install' command to create a new 'iOS Example.xcworkspace' file in the 'iOS Example' folder
    • adding all the supported languages in 'iOS Example' project

    With this modifications, to run the example: open the 'iOS Example.xcworkspace' file in the 'iOS Example' folder.

    opened by filograno 10
  • Orientation Issue

    Orientation Issue

    Here is the problem I have. I take a picture on my iPhone 5 on the camera and email it to myself. If i go to upload it to a blog or facebook it is always turned sideways. I have to open it on preview and re-save it so it has the correct orientation (even though i did not make any changes). where as landscape images are fine.

    opened by ghousesgb 8
  • Swift support?

    Swift support?

    Hi

    I tried adding the library with pods and then #import "FDTakeController.h" in my bridging file but I get:

    /Users/dgomez/Desktop/Swift - Camera/Swift - Camera/Swift - Camera-Bridging-Header.h:5:9: note: in file included from /Users/dgomez/Desktop/Swift - Camera/Swift - Camera/Swift - Camera-Bridging-Header.h:5:
    #import "FDTakeController.h"
            ^
    /Users/dgomez/Desktop/Swift - Camera/Pods/Headers/Public/FDTake/FDTakeController.h:29:65: error: expected a type
    - (void)takeController:(FDTakeController *)controller gotPhoto:(UIImage *)photo withInfo:(NSDictionary *)info;
                                                                    ^
    /Users/dgomez/Desktop/Swift - Camera/Swift - Camera/Swift - Camera-Bridging-Header.h:5:9: note: in file included from /Users/dgomez/Desktop/Swift - Camera/Swift - Camera/Swift - Camera-Bridging-Header.h:5:
    #import "FDTakeController.h"
            ^
    /Users/dgomez/Desktop/Swift - Camera/Pods/Headers/Public/FDTake/FDTakeController.h:37:41: error: cannot find protocol declaration for 'UIImagePickerControllerDelegate'
    @interface FDTakeController : NSObject <UIImagePickerControllerDelegate>
                                            ^
    /Users/dgomez/Desktop/Swift - Camera/Swift - Camera/Swift - Camera-Bridging-Header.h:5:9: note: in file included from /Users/dgomez/Desktop/Swift - Camera/Swift - Camera/Swift - Camera-Bridging-Header.h:5:
    #import "FDTakeController.h"
            ^
    /Users/dgomez/Desktop/Swift - Camera/Pods/Headers/Public/FDTake/FDTakeController.h:59:42: error: unknown type name 'UIViewController'
    @property (nonatomic, unsafe_unretained) UIViewController *viewControllerForPresentingImagePickerController;
                                             ^
    /Users/dgomez/Desktop/Swift - Camera/Swift - Camera/Swift - Camera-Bridging-Header.h:5:9: note: in file included from /Users/dgomez/Desktop/Swift - Camera/Swift - Camera/Swift - Camera-Bridging-Header.h:5:
    #import "FDTakeController.h"
            ^
    /Users/dgomez/Desktop/Swift - Camera/Pods/Headers/Public/FDTake/FDTakeController.h:61:31: error: unknown type name 'UITabBar'
    @property (strong, nonatomic) UITabBar *tabBar;
                                  ^
    /Users/dgomez/Desktop/Swift - Camera/Swift - Camera/Swift - Camera-Bridging-Header.h:5:9: note: in file included from /Users/dgomez/Desktop/Swift - Camera/Swift - Camera/Swift - Camera-Bridging-Header.h:5:
    #import "FDTakeController.h"
            ^
    /Users/dgomez/Desktop/Swift - Camera/Pods/Headers/Public/FDTake/FDTakeController.h:61:1: error: property with 'retain (or strong)' attribute must be of object type
    @property (strong, nonatomic) UITabBar *tabBar;
    ^
    <unknown>:0: error: failed to import bridging header '/Users/dgomez/Desktop/Swift - Camera/Swift - Camera/Swift - Camera-Bridging-Header.h'```
    
    opened by danielgomezrico 7
  • FDTakeController deinit is not being called. Seems to be a memory leak for me.

    FDTakeController deinit is not being called. Seems to be a memory leak for me.

    Hello Guys, I have such method to show FDTake at my view controller. Code at my ViewController:

    fileprivate var fdTakeController: FDTakeController!
    
     func showFDTakeController() {
            fdTakeController = ImageManager.fdTakeController
            fdTakeController.didFail = { [unowned self] in
                let alert = UIAlertController(title: "Failed", message: "User selected but API failed", preferredStyle: .alert)
                alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
                self.present(alert, animated: true, completion: nil)
            }
            fdTakeController.didGetPhoto = { [unowned self]
                (image: UIImage, info: [AnyHashable : Any]) in
                self.avatarButton.setImage(image, for: .normal)
                self.avatarButton.setImage(image, for: .highlighted)
                self.memberService.imageData = UIImageJPEGRepresentation(image, 0.5)
            }
            self.fdTakeController.presentingView = self.view
            self.fdTakeController.present()
       }
    

    Problem is, that when I go away from my controller, its deinit is being called as it should to be. However I noticed, that deinit of FDTake controller is not called. Could you tell me, maybe I did something wrong at implementation of FDTake at my controller. Because it causes memory leak.

    opened by Kharauzov 5
  • Swift 3 conversion

    Swift 3 conversion

    The swift 3 conversion is completed here for you. The framework should build and operate properly when linked to another application.

    There is an Xcode linker error when running the example project that I wasn't able to figure out. You may have more luck with that.

    dyld: Library not loaded: @rpath/FDTake.framework/FDTake
      Referenced from: /Users/Anthony/Library/Developer/CoreSimulator/Devices/4CEB8CFD-4B0F-45E8-846D-09CF7472E62E/data/Containers/Bundle/Application/68D448FF-F227-4B53-A7E0-4D33C458B135/FDTake_Example.app/FDTake_Example
      Reason: image not found
    
    opened by AnthonyMDev 5
  • Localization not working properly? [HELP NEEDED]

    Localization not working properly? [HELP NEEDED]

    Hi, thanks for a neat library.

    I have placed the Localizable.strings from the English and Danish under a Supporting Files group, and I can see they have been added to en.lproj and da.lproj. I can see they are picked up:

    image

    The pop-up does not seem to be translated however, it will just say "takePhoto" for example. I know the Localizable.strings files are working, because I have this line

    label.text = NSLocalizedString("loading", comment: "The loading message when pulling data")
    

    and that changes correctly if I choose Danish or English.

    Any idea if I am doing something wrong here? I copied them into the project, no reference link. I do not use CocoaPods. Content of the English Localizable.strings:

    /* Decline to proceed with operation */
    "cancel" = "Cancel";
    
    /* Option to select photo from library */
    "chooseFromLibrary" = "Choose from library";
    
    /* Option to select photo from photo roll */
    "chooseFromPhotoRoll" = "Choose from photo roll";
    
    /* There are no sources available to select a photo */
    "noSources" = "There are no sources available to select a photo";
    
    /* Option to take photo using camera */
    "takePhoto" = "Take photo";
    
    /* Option to take video using camera */
    "takeVideo" = "Take video";
    
    /* The loading message when pulling data */
    "loading" = "Loading...";
    

    Thank you.

    opened by lauritzsh 5
  • iPad landscape problems

    iPad landscape problems

    On iPad this pod is working fine in portrait mode, however when presenting the popover controller in landscape mode the camera view is still in portrait. Taking a picture in landscape mode with the viewfinder in portrait, sets the image correct in landscape. So the problem is only occurring while finding your target.

    From what i can find on google, maybe this is a Apple thing with the UIImagePickerController.

    opened by kaspernissen 5
  • Use last photo taken [HELP NEEDED]

    Use last photo taken [HELP NEEDED]

    Many Applications nowadays offer

    • last photo taken
    • take photo
    • choose from library

    I use the first option all the time. It would be swell if FDTake would offer this feature.

    enhancement help wanted 
    opened by mdornseif 5
  • Module deployment target issue

    Module deployment target issue

    HI When I have tried to build using Cocoapods, I have set my build target to 8.0 but I get this error when trying to build: Module file's minimum deployment target is ios8.0 v8.0:

    Any ideas how to resolve?

    opened by grantkemp 4
  • Constraint break after click present fd

    Constraint break after click present fd

    hi dear support constraint has been break as describe below here:

    [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "<NSLayoutConstraint:0x6000033386e0 UIView:0x7fa4f344aeb0.width == - 16 (active)>" )

    Will attempt to recover by breaking constraint <NSLayoutConstraint:0x6000033386e0 UIView:0x7fa4f344aeb0.width == - 16 (active)>

    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

    opened by hafiz013 2
  • Can this library choose multiple image from library

    Can this library choose multiple image from library

    Hi dear support, is this library can support to pick up multiple image from library or gallery. If can't please do so. As this library benefit for all ios developer out there.

    enhancement 
    opened by hafiz013 3
  • Deprecated function in iOS 9.0

    Deprecated function in iOS 9.0

    Hi there developer please update your function since it is depreciated inside ios 9.0.

    UIApplication.shared.isStatusBarHidden = true

    under class : extension FDTakeController : UIImagePickerControllerDelegate, UINavigationControllerDelegate

    and under function public func imagePickerControllerDidCance

    bug help wanted valid 
    opened by hafiz013 9
  • Add Custom Crop ViewController

    Add Custom Crop ViewController

    In order to enable for custom aspect ratio when cropping.

    Can't make tests pass on Travis though, due to the error message:

    “Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.

    I believe this is an error on xcbuild or something must be outdated on Travis CI server side. Also, didn't check the .travis.yml, something might be wrong there.

    opened by carlosmouracorreia 3
Releases(3.1.0)
Owner
William Entriken
EN/中文 [email protected]
William Entriken
Swift library to easily check the current device and some more info about it.

Usage To run the example project, clone the repo, and run pod install from the Example directory first. let device = Deviice.current device is a Devi

Andrea Mario Lufino 56 Nov 3, 2022
Easily communicate between iOS/OSX devices using BLE

BluetoothKit Easily communicate between iOS devices using BLE. Background Apple mostly did a great job with the CoreBluetooth API, but because it enca

Rasmus Høhndorf Hummelmose 2.1k Dec 29, 2022
iOS & OSX Bluetooth library for RxSwift

RxBluetoothKit is a Bluetooth library that makes interaction with BLE devices much more pleasant. It's backed by RxSwift and CoreBluetooth and it prov

Polidea 1.3k Dec 16, 2022
Library for iOS Camera API. Massively increase performance and ease of use within your next iOS Project.

CameraKit helps you add reliable camera to your app quickly. Our open source camera platform provides consistent capture results, service that scales,

CameraKit 628 Dec 27, 2022
Super-lightweight library to detect used device

Device.swift Super-lightweight library to detect used device Device.swift extends the UIDevice class by adding a property: var deviceType: DeviceType

Johannes Schickling 219 Nov 17, 2022
Lightweight Cocoa library for detecting the running device's model and screen size.

Lightweight Cocoa library for detecting the running device's model and screen size. With the newer  devices, developers have more work to do. This li

Sebastian Dobrincu 1.3k Nov 24, 2022
Easily take a photo or video or choose from library

FDTake Easily take a photo or video or choose from library ?? Author's tip jar: https://amazon.com/hz/wishlist/ls/EE78A23EEGQB Usage To run the exampl

William Entriken 322 Nov 30, 2022
PowerUp is an educational choose-your-own-adventure game that utilizes a users uploaded curriculum to empower pre-adolescents to take charge of their reproductive health.

PowerUp is an educational choose-your-own-adventure game that utilizes a users uploaded curriculum to empower pre-adolescents to take charge of their reproductive health. This is the iOS version of the game.

AnitaB.org Open Source 39 Sep 26, 2022
Video mp4 record save display - How to Take , Save and Display a .mp4 Video

Technicalisto How to Take , Save and Display a .mp4 Video Add your design with v

Aya Baghdadi 2 Aug 7, 2022
DTPhotoViewerController - A fully customizable photo viewer ViewController to display single photo or collection of photos, inspired by Facebook photo viewer.

DTPhotoViewerController Example Demo video: https://youtu.be/aTLx4M4zsKk DTPhotoViewerController is very simple to use, if you want to display only on

Tung Vo 277 Dec 17, 2022
Jogendra 113 Nov 28, 2022
JDVideoKit - You can easily transfer your video into Three common video type.

JDVideoKit Introduction You can easily transfer your video into Three common video type. You can use set up camera easily. Installation pod 'JDVideoK

郭介騵 24 Sep 9, 2021
A Swift library to design custom prompts with a great scope of options to choose from.

Installation CocoaPods Install with CocoaPods by adding the following to your Podfile: source 'https://github.com/CocoaPods/Specs.git' platform :ios,

Gabriel Alvarado 736 Nov 3, 2022
FYPhoto is a photo/video picker and image browser library for iOS written in pure Swift. It is feature-rich and highly customizable to match your App's requirements.

FYPhoto is a photo/video picker and image browser library for iOS written in pure Swift. It is feature-rich and highly customizable to match your App's requirements.

null 10 Dec 11, 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
Shows your photo library grouped by events, to easily export them to your computer

Groupir Shows your photo library grouped by events, to easily export them to your computer Features Currently supported features: reading your photo l

Stanislas Chevallier 0 Dec 15, 2021
Reel Search is a Swift UI controller that allows you to choose options from a list

REEL SEARCH Reel Search is a Swift UI controller that allows you to choose options from a list We specialize in the designing and coding of custom UI

Ramotion 2.5k Dec 21, 2022