Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

An ARC-ified, more modular design of the EGO PhotoViewer

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 Classes
Octocat-spinner-32 Demo
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .gitmodules
Octocat-spinner-32 README.mdown
README.mdown

EGOPhotoViewer

About

EGOPhotoViewer allows you to quickly load an display single or multiple images from a local source or remote source. EGOPhotoViewer is a sub-class of a UIViewController.

Support

This ARC Enabled library supports both iPhone and iPad.

History

Enormego wrote:

EGOPhotoViewer was originally started as a stripped down version of three20's PhotoViewer. We ultimately decided the three20 code base was not flexible enough and scrapped the project all together. We rewrote PhotoViewer as EGOPhotoViewer from scratch, based upon our reliable open source libraries EGOCache and EGOImageLoading.

I have used EGOPhotoViewer on two iOS projects and found there were limitations that this fork remedies.

  • A more modular approach for the action button

    The original project's implementation did not now allow the developer to control the action menu. When I wanted to integrate a more robust sharing solution I had to delete methods and actions that likely should not have ever been in the EGOPhotoViewController. Now a user can specify a view controller that adheres to the EGOActionViewController protocol.

    Sharing with Share Kit

  • A more modular approach for the caption view

    The origin implementation of the caption view lacked the ability to customize the caption view. So I also made that more modular. Creating a EGOCaptionView protocol with two implementations: EGOSimplePhotoCaptionView which is the original simple caption view; EGODetailedCaptionView which provides support for additional fields like title, source, and published.

    Detailed Caption

  • A thumbnail view

    An button that would open a thumbnail view, allowing the user to view all the images within the photo source at a quick glance.

    Thumbnail View

  • The project is now ARC compatible

    Along with making ARC compatible I removed a number of previous code checks that were asking if the software version was above a certain number. I wanted this library to be ready and available for future projects.

Examples

The Demo project contains a number of examples of creating and configuring the EGOPhotoViewer.

Photos and Photo Sources

You are able to create a photo viewer with a single image, url, or an object adhering to the EGOPhoto protocol:

- (id)initWithPhoto:(id<EGOPhoto>)aPhoto;
- (id)initWithImage:(UIImage*)image;
- (id)initWithImageURL:(NSURL*)imageURL;

or with multiple images, urls, or an object adhering to the EGOPhotoSource protocol:

- (id)initWithPhotoSource:(id <EGOPhotoSource>)aPhotoSource;
- (id)initWithImages:(NSArray *)images;
- (id)initWithImageURLs:(NSArray *)imageURLs;
- (id)initWithPhotoSource:(id <EGOPhotoSource>)aSource andPhotoIndex:(NSInteger)index;

Using a UIImage or NSURL will automatically wrap those values in a EGODefaultPhoto and that photo in a EGODefaultPhotoSource. However, you can specify your own implementations or provide the photo source. Creating and configuring your own photo and photo source allows you the ability to specify additional metadata with your photos:

EGODefaultPhoto *photo = [[EGODefaultPhoto alloc] initWithImageURL:[NSURL URLWithString:@"http://a3.twimg.com/profile_images/66601193/cactus.jpg"]];

photo.title = @"Grass From Around the World";
photo.caption = @"This grass in particular was soft and lush...";
photo.published = @"Some Time Ago...";
photo.source = @"Ms. Photog";

EGODefaultPhotoSource *source = [[EGODefaultPhotoSource alloc] initWithPhotos:[NSArray arrayWithObject:photo]];

source.sourceTitle = @"Chupacabra Revealed";
source.sourceDescription = @"We tracked the Chupacabra to it's den near ...";

EGOPhotoViewController *photoController = [[EGOPhotoViewController alloc] initWithPhotoSource:source];

Custom Caption View

By default the caption view will default to the EGOSimplePhotoCaptionView. This caption view allows for a small amount of a photo's caption text to appear with the photo when the tool bars are visible.

The library also includes EGODetailedCaptionView, which display's a photo's source, published datetime, title, and caption. The title and caption area contained in a scroll view to allow their size to adapt to the size of text without overtaking the entire photo view.

#import "EGODetailedCaptionView.h"
id<EGOPhotoSource> source = [self examplePhotoSourceWithVariedPhotos];
EGOPhotoViewController *photoController = [[EGOPhotoViewController alloc] initWithPhotoSource:source];
photoController.captionView = [[EGODetailedCaptionView alloc] init];

You can design your own Caption view simply by defining a UIView that adheres to the EGOCaptionView protocol.

@interface EGOMyPhotoCaptionView : UIView <EGOCaptionView>

@end

@implementation EGOMyPhotoCaptionView

@synthesize photo = photo_;

- (void)setPhoto:(id<EGOPhoto>)photo {

    if (photo_ == photo) { return; }
    photo_ = photo;

    // Setup the remaining details about the view with 
    // the object that adheres to EGOPhoto
}

Custom ActionViewController

Previously EGOPhotoViewer required that you use the basic action sheet for the current image. When I needed more options I immediately removed all that code and replaced it with ShareKit.

The demo project shows an example of integrating the default actions and the Sharekit library.

id<EGOPhotoSource> source = [self examplePhotoSourceWithVariedPhotos];
EGOPhotoViewController *photoController = [[EGOPhotoViewController alloc] initWithPhotoSource:source];
photoController.actionViewController = [[SHKActionViewController alloc] init];

Currently the EGOActionViewController interface employs iOS SDK 5.0's UIViewController containment. Adding the UIViewController as a childViewController and adding the view to the view. However, there is no formally defined dismissal yet in this protocol, so it is on view controller adhering to the EGOAtionViewController to remove itself from the parent view controller and remove the it's view.

This works well with the UIActionSheet examples. This likely does not work well yet with other custom view controllers.

Future Work

Some of the above features, like the action button and thumbnail view, are very limited. They currently do not have very graceful presentations, do not support rotation very well, and are not well tested on the iPad.

There also remains a large number of features that are still not very configurable within this application that I would like to make easier to make more modular so that they are easier to replace and configure.

License

EGOPhotoViewer is available under the MIT license:

Copyright (c) 2012 Franklin Webber

Copyright (c) 2010 enormego

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.