Giter Club home page Giter Club logo

photoviewer's Introduction

PhotoViewer

PhotoViewer provides a method for displaying images from Web or local file. it includes SDWebImage so it has features that SDWebImage has.

How to Install

Just draging class files to your project.

Usage

Getting start with PhotoViewer is dead simple. Just initialize it with delegate. Like this: self.pvc = [[PhotoViewer alloc] initWithDelegate:self];

If you want to display a specific index of photo when PhotoViewer shows, you should assign a number to "currentPageIndex", Like this: self.pvc.currentPageIndex = 3;

PhotoViewr provides view controller Animated transition if implements transitionDelegate of PhotoViewer class. Like this: self.pvc.transitioningDelegate = self;

Then you must implement:

  • (id)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source { if ([presented isKindOfClass:PhotoViewer.class]) { return [[ImageZoomPresentAnimation alloc] initWithReferenceImageView:[self referenceImageView]]; } return nil; }

  • (id)animationControllerForDismissedController:(UIViewController *)dismissed { if ([dismissed isKindOfClass:PhotoViewer.class]) { return [[ImageZoomPresentAnimation alloc] initWithReferenceImageView:[self referenceImageView]]; } return nil; }

You should take responsibility for calculating the right position of image view. If images is in a table view cell, you should use convertRect:fromView: method to calculate the frame. Maybe like this: [self.view convertRect:imageView fromView: cell]; If images is in a UIView, maybe you can just pass the frame of image view itself. Both two situations mentioned above are in the Demo project.

PhotoViewer has several delegate methods:

@protocol PhotoViewerDelegate

  • (void)dismissViewController;

  • (NSUInteger)numberOfPhotos;

  • (UIImage *)photoViewer: (PhotoViewer *)photoViewer thumbnailAtIndex: (NSUInteger)index;

@optional // Uses photoViewer:photoAtIndex: first

  • (UIImage *)photoViewer: (PhotoViewer *)photoViewer photoAtIndex: (NSUInteger)index; // If can not find photoViewer:photoAtIndex:, then uses photoViewer:photoUrlAtIndex:
  • (NSString *)photoViewer: (PhotoViewer *)photoViewer photoUrlAtIndex: (NSUInteger)index;

@end

PhotoViewer will call photoViewer:photoAtIndex: first. If it can't get a UIImage Object, then it calls photoViewer:photoUrlAtIndex: . thumnail is used as placeholder when downloading images from Internet and also used for view controller transition.

You'd better implement the dismissViewController method, and note that only if you call the dissmissViewControllerAnimated: completion: method with animated: YES, PhotoViewer can perform animation while dismissing.

photoviewer's People

Contributors

xuzhaocheng avatar

Stargazers

 avatar

Watchers

 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.