Photo Browser / Viewer inspired by Facebook's and Tweetbot's with ARC support, swipe-to-dismiss, image progress and more

Overview

IDMPhotoBrowser

IDMPhotoBrowser is a new implementation based on MWPhotoBrowser.

We've added both user experience and technical features inspired by Facebook's and Tweetbot's photo browsers.

New features:

  • Uses ARC
  • Uses SDWebImage for image loading
  • Image progress shown
  • Minimalistic Facebook-like interface, swipe up/down to dismiss
  • Ability to add custom actions on the action sheet

Features

  • Can display one or more images by providing either UIImage objects, file paths to images on the device, or URLs to images online
  • Handles the downloading and caching of photos from the web seamlessly
  • Photos can be zoomed and panned, and optional captions can be displayed

Screenshots

Alt Alt Alt Alt Alt

Usage

See the code snippet below for an example of how to implement the photo browser.

First create a photos array containing IDMPhoto objects:

// URLs array
NSArray *photosURL = @[[NSURL URLWithString:@"http://farm4.static.flickr.com/3567/3523321514_371d9ac42f_b.jpg"], 
[NSURL URLWithString:@"http://farm4.static.flickr.com/3629/3339128908_7aecabc34b_b.jpg"], 
[NSURL URLWithString:@"http://farm4.static.flickr.com/3364/3338617424_7ff836d55f_b.jpg"], 
[NSURL URLWithString:@"http://farm4.static.flickr.com/3590/3329114220_5fbc5bc92b_b.jpg"]];
    
// Create an array to store IDMPhoto objects
NSMutableArray *photos = [NSMutableArray new];

for (NSURL *url in photosURL) {
	IDMPhoto *photo = [IDMPhoto photoWithURL:url];
	[photos addObject:photo];
}
	
// Or use this constructor to receive an NSArray of IDMPhoto objects from your NSURL objects
NSArray *photos = [IDMPhoto photosWithURLs:photosURL];

There are two main ways to presente the photoBrowser, with a fade on screen or with a zooming effect from an existing view.

Using a simple fade transition:

IDMPhotoBrowser *browser = [[IDMPhotoBrowser alloc] initWithPhotos:photos];

Zooming effect from a view:

IDMPhotoBrowser *browser = [[IDMPhotoBrowser alloc] initWithPhotos:photos animatedFromView:sender];

When using this animation you can set the scaleImage property, in case the image from the view is not the same as the one that will be shown on the browser, so it will dynamically scale it:

browser.scaleImage = buttonSender.currentImage;

Presenting using a modal view controller:

[self presentViewController:browser animated:YES completion:nil];

Customization

Toolbar

You can customize the toolbar. There are three boolean properties you can set: displayActionButton (default is YES), displayArrowButton (default is YES) and displayCounterLabel (default is NO). If you dont want the toolbar at all, you can set displayToolbar = NO.

Toolbar setup example:

browser.displayActionButton = NO;
browser.displayArrowButton = YES;
browser.displayCounterLabel = YES;

It is possible to use your own image on the toolbar arrows:

browser.leftArrowImage = [UIImage imageNamed:@"IDMPhotoBrowser_customArrowLeft.png"];
browser.rightArrowImage = [UIImage imageNamed:@"IDMPhotoBrowser_customArrowRight.png"];
browser.leftArrowSelectedImage = [UIImage imageNamed:@"IDMPhotoBrowser_customArrowLeftSelected.png"];
browser.rightArrowSelectedImage = [UIImage imageNamed:@"IDMPhotoBrowser_customArrowRightSelected.png"];

If you want to use custom actions, set the actionButtonTitles array with the titles for the actionSheet. Then, implement the photoBrowser:didDismissActionSheetWithButtonIndex:photoIndex: method, from the IDMPhotoBrowser delegate

browser.actionButtonTitles = @[@"Option 1", @"Option 2", @"Option 3", @"Option 4"];

Others

Others customizations you can make are: use white background color, don't display the done button and change the done button background image:

browser.useWhiteBackgroundColor = YES;
browser.displayDoneButton = NO;
browser.doneButtonImage = [UIImage imageNamed:@"IDMPhotoBrowser_customDoneButton.png"];

If you want to keep the interface shown when the user is scrolling :

browser.autoHideInterface = NO;

You can use a smooth pop animation when presenting and dismissing a photo:

browser.usePopAnimation = YES;

If the presenting view controller doesn't have a status bar, in some cases you can force it to be hidden:

browser.forceHideStatusBar = YES;

It's possible to disable the vertical dismiss swipe gesture:

browser.disableVerticalSwipe = YES;

Dismiss the photo browser with a touch (instead of showing/hiding controls):

browser.dismissOnTouch = YES;

Photo Captions

Photo captions can be displayed simply by setting the caption property on specific photos:

IDMPhoto *photo = [IDMPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"photo2l" ofType:@"jpg"]];
photo.caption = @"Campervan";

No caption will be displayed if the caption property is not set.

Custom Captions

By default, the caption is a simple black transparent view with a label displaying the photo's caption in white. If you want to implement your own caption view, follow these steps:

  1. Optionally use a subclass of IDMPhoto for your photos so you can store more data than a simple caption string.
  2. Subclass IDMCaptionView and override -setupCaption and -sizeThatFits: (and any other UIView methods you see fit) to layout your own view and set it's size. More information on this can be found in IDMCaptionView.h
  3. Implement the -photoBrowser:captionViewForPhotoAtIndex: IDMPhotoBrowser delegate method (shown below).

Example delegate method for custom caption view:

- (IDMCaptionView *)photoBrowser:(IDMPhotoBrowser *)photoBrowser captionViewForPhotoAtIndex:(NSUInteger)index {
	IDMPhoto *photo = [self.photos objectAtIndex:index];
	MyIDMCaptionViewSubclass *captionView = [[MyIDMCaptionViewSubclass alloc] initWithPhoto:photo];
	return captionView;
}

Adding to your project

Using CocoaPods

Just add pod 'IDMPhotoBrowser' to your Podfile.

Including Source Directly Into Your Project

Opensource libraries used

Licence

This project uses MIT License.

Comments
  • crash when user taps the done button without waiting for the whole image to download

    crash when user taps the done button without waiting for the whole image to download

    Hello i experienced a crash right when the user taps on a cell image, the modal opens and the progress is being shown to download an image from the web. if you do not wait for the whole image to download and hit the DONE button the method performCloseAnimationWithScrollView crashes when setting the resizableImageView frame size, since the imageFromView is nil.

    a solution would be an if statement like this: if (imageFromView == nil) { // in case the user taps the DONE button without // waiting for the whole image to download resizableImageView.frame = CGRectZero; } else{ .......

    if you find any better solution please share.

    thanks

    opened by mythodeia 7
  • Zoom scale is too large when image is long from side to side

    Zoom scale is too large when image is long from side to side

    If the image is long from side to side, zoom scale become too large.

    | Service | Original | Zoom | | --- | --- | --- | | IDMPhotoBrowser | | | | Facebook | | |

    opened by yukitoto 5
  • Use cocoapods for demo project

    Use cocoapods for demo project

    Essentially, this pull request makes it such that the AFNetworking, DACircularProgress, SVProgressHUD dependencies in the demo project are managed via Cocoapods.

    opened by sibljon 5
  • Linker Error _OBJC_CLASS_$IDMPhoto and IDMPhotoBrowser

    Linker Error _OBJC_CLASS_$IDMPhoto and IDMPhotoBrowser

    Hey man,

    Im probably doing something wrong here, but I'm getting 3 Linker errors on my project. I imported all the classes to my project and tried to make a simple displayer, made the

    import "IDMPhotoBrowser.h" and wrote the code.

    Ill attach some images that might help you in helping me :) Thanks very much.

    screen shot 2013-08-23 at 6 16 51 pm

    screen shot 2013-08-23 at 6 16 26 pm

    screen shot 2013-08-23 at 6 16 38 pm

    opened by chmiiller 5
  • Resource bundle is not seen if

    Resource bundle is not seen if "use_frameworks" is used in Podfile.

    I tried to use IDMPhotoBrowser with Swift (>2.1) project, but I found if I enable using "use_frameworks" in the Podfile, the strings referenced from IDMPBLocalizations.bundle is not retrieved, (null) string is returned. Then the expected "1 of 5" becomes "1 (null) 5", as well as the caption of Done button becomes empty. Can you fix this problem?

    opened by imadeit 4
  • setInitialPageIndex strange animation if not first image

    setInitialPageIndex strange animation if not first image

    Hi,

    if i use setInitialPageIndex and opens the Photo Browser the animation is strange. It animates from the first image to the initial page index, also on hiding the browser.

    If i open from the first image the animation is fine.

    Any ideas?

    opened by x2on 4
  • double tap zooming issue in iOS 8

    double tap zooming issue in iOS 8

    seems like a easy fix. please refer to this https://github.com/mwaterfall/MWPhotoBrowser/issues/304

    simply added: +- (void)scrollViewDidZoom:(UIScrollView *)scrollView {

    • [self setNeedsLayout];
    • [self layoutIfNeeded]; +}
    opened by kiddomk 4
  • Allow iOS 6 in pod spec

    Allow iOS 6 in pod spec

    Seems like an oversight in the latest podspec as I've tested the latest 1.3.2 code on iOS 6.0 and it seems to be working without issue.

    See issue https://github.com/ideaismobile/IDMPhotoBrowser/issues/47

    opened by palringosteve 4
  • Wrong photo loaded when rotating last photo

    Wrong photo loaded when rotating last photo

    You can simulate this error on de demo project.

    1 - Choose "Photos form flick custom" 2 - Go to the last photo 3 - Rotate the device.

    It shows the wrong photo.

    It only happens on the last photo.

    BTW thanks for this amazing control !

    opened by rscrespo 4
  • Problem with iOS 7 presenting the the browser through navigation controller

    Problem with iOS 7 presenting the the browser through navigation controller

    Using the browser in iOS 7 and presenting it through navigation controller causes the first image to appear clipped to the top region. Also the image can be scrolled to top and bottom.

    screen

    But flipping to the next image removes the problem, How ever the images can be scrolled in all directions, can it get fiexed. Please concentrate on iOS 7 coz i need to update my app.

    opened by ghost 4
  • Allow a photo to provide a placeholder/preview image

    Allow a photo to provide a placeholder/preview image

    This allows a photo to have a placeholder image. This allows a thumbnail or preview image to be displayed while the full size photo is being loaded from the network.

    I also slightly improved the presentation animation by fading in the alpha of the scroll view instead of just the view.

    opened by wlisac 3
  • Zoom scale controlled from outside ; implemented.

    Zoom scale controlled from outside ; implemented.

    -Earlier, the max zoom scale was fixed ( 4.0, maximumDoubleTapZoomScale), so if someone wants to zoom more on double click, it was not possible. Now, we can set the zoom-in scale value from the implementation class.

    • pod updated
    • Swift code updated
    opened by jams032 1
  • Please add SPM Suport

    Please add SPM Suport

    Please add Swift Package Manager support

    SDWebImage already supports SPM in 6.0 branch DACircularProgress supports SPM in https://github.com/tgymnich/DACircularProgress fork

    opened by Cy-4AH 0
  • Fix warning: MobileCoreServices has been renamed.

    Fix warning: MobileCoreServices has been renamed.

    Close #315

    If our library was installed via CocoaPods, Xcode 11.4 will issue the warning "MobileCoreServices has been renamed. Use CoreServices instead.".

    image

    How to fix: Do not explicitly link MobileCoreServices.framework in the CocoaPods generated project, by deleting MobileCoreServices from the spec.frameworks attribute in our podspec file.

    More info: https://github.com/AFNetworking/AFNetworking/pull/4532

    opened by ElfSundae 2
  • MobileCoreServices has been renamed to CoreServices in Xcode 11.4

    MobileCoreServices has been renamed to CoreServices in Xcode 11.4

    I get a compiler warning MobileCoreServices has been renamed. Use CoreServices instead. after upgrading to Xcode 11.4. Manually adding CoreServices framework to IDMPhotoBrowser target and removing MobileCoreServices resolves the warning, but you'll need to do this every time you update pods.

    opened by jonathanfoster 0
  • The way to solve image twinkling on iOS13

    The way to solve image twinkling on iOS13

    before presenting the PhotoBrowser, change the modal presentStyle to overCurrentContext

    photoBrowser.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    

    hope it will help some one :D

    opened by Cookiezby 0
Owner
Thiago Peres
Thiago Peres
Jogendra 113 Nov 28, 2022
Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift

SKPhotoBrowser [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-) Simple PhotoBrowser

keishi suzuki 2.4k Jan 6, 2023
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
Image viewer (or Lightbox) with support for local and remote videos and images

Table of Contents Features Focus Browse Rotation Zoom tvOS Setup Installation License Author Features Focus Select an image to enter into lightbox mod

Nes 534 Jan 3, 2023
Agrume - 🍋 An iOS image viewer written in Swift with support for multiple images.

Agrume An iOS image viewer written in Swift with support for multiple images. Requirements Swift 5.0 iOS 9.0+ Xcode 10.2+ Installation Use Swift Packa

Jan Gorman 601 Dec 26, 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
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 Jan 5, 2023
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 Dec 27, 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
Lightbox is a convenient and easy to use image viewer for your iOS app

Lightbox is a convenient and easy to use image viewer for your iOS app, packed with all the features you expect: Paginated image slideshow. V

HyperRedink 1.5k Dec 22, 2022
Swift image slideshow with circular scrolling, timer and full screen viewer

?? ImageSlideshow Customizable Swift image slideshow with circular scrolling, timer and full screen viewer ?? Example To run the example project, clon

Petr Zvoníček 1.7k Dec 21, 2022
A snappy image viewer with zoom and interactive dismissal transition.

A snappy image viewer with zoom and interactive dismissal transition. Features Double tap to zoom in/out Interactive dismissal transition Animate in f

Lucas 421 Dec 1, 2022
Slide image viewer library similar to Twitter and LINE.

Overview You can use it simply by passing the necessary information! Serrata is a UI library that allows you to intuitively view images. Features King

Takuma Horiuchi 324 Dec 9, 2022
A snappy image viewer with zoom and interactive dismissal transition.

A snappy image viewer with zoom and interactive dismissal transition. Features Double tap to zoom in/out Interactive dismissal transition Animate in f

Lucas 421 Dec 1, 2022
Image slide-show viewer with multiple predefined transition styles, with ability to create new transitions with ease.

ATGMediaBrowser ATGMediaBrowser is an image slide-show viewer that supports multiple predefined transition styles, and also allows the client to defin

null 200 Dec 19, 2022
An image viewer à la Twitter

For the latest changes see the CHANGELOG Install CocoaPods pod 'ImageViewer' Carthage github "Krisiacik/ImageViewer" Sample Usage For a detailed examp

Kristian Angyal 2.4k Dec 29, 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