GithubHelp home page GithubHelp logo

mwaterfall / mwphotobrowser Goto Github PK

View Code? Open in Web Editor NEW
8.7K 300.0 2.7K 21.23 MB

A simple iOS photo and video browser with grid view, captions and selections.

License: MIT License

Objective-C 97.15% Ruby 0.37% Shell 2.48%

mwphotobrowser's Introduction

MWPhotoBrowser

Version License Platform

Flattr this git repo

A simple iOS photo and video browser with optional grid view, captions and selections.

MWPhotoBrowser can display one or more images or videos by providing either UIImage objects, PHAsset objects, or URLs to library assets, web images/videos or local files. The photo browser handles the downloading and caching of photos from the web seamlessly. Photos can be zoomed and panned, and optional (customisable) captions can be displayed.

The browser can also be used to allow the user to select one or more photos using either the grid or main image view.

Alt    Alt    Alt    Alt    Alt    Alt

Works on iOS 7+. All strings are localisable so they can be used in apps that support multiple languages.

Usage

MWPhotoBrowser is designed to be presented within a navigation controller. Simply set the delegate (which must conform to MWPhotoBrowserDelegate) and implement the 2 required delegate methods to provide the photo browser with the data in the form of MWPhoto objects. You can create an MWPhoto object by providing a UIImage object, PHAsset object, or a URL containing the path to a file, an image online or an asset from the asset library.

MWPhoto objects handle caching, file management, downloading of web images, and various optimisations for you. If however you would like to use your own data model to represent photos you can simply ensure your model conforms to the MWPhoto protocol. You can then handle the management of caching, downloads, etc, yourself. More information on this can be found in MWPhotoProtocol.h.

See the code snippet below for an example of how to implement the photo browser. There is also a simple demo app within the project.

// Create array of MWPhoto objects
self.photos = [NSMutableArray array];

// Add photos
[photos addObject:[MWPhoto photoWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"photo2l" ofType:@"jpg"]]]];
[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3629/3339128908_7aecabc34b.jpg"]]];
[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3590/3329114220_5fbc5bc92b.jpg"]]];

// Add video with poster photo
MWPhoto *video = [MWPhoto photoWithURL:[NSURL URLWithString:@"https://scontent.cdninstagram.com/hphotos-xpt1/t51.2885-15/e15/11192696_824079697688618_1761661_n.jpg"]];
video.videoURL = [[NSURL alloc] initWithString:@"https://scontent.cdninstagram.com/hphotos-xpa1/t50.2886-16/11200303_1440130956287424_1714699187_n.mp4"];
[photos addObject:video];

// Create browser (must be done each time photo browser is
// displayed. Photo browser objects cannot be re-used)
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];

// Set options
browser.displayActionButton = YES; // Show action button to allow sharing, copying, etc (defaults to YES)
browser.displayNavArrows = NO; // Whether to display left and right nav arrows on toolbar (defaults to NO)
browser.displaySelectionButtons = NO; // Whether selection buttons are shown on each image (defaults to NO)
browser.zoomPhotosToFill = YES; // Images that almost fill the screen will be initially zoomed to fill (defaults to YES)
browser.alwaysShowControls = NO; // Allows to control whether the bars and controls are always visible or whether they fade away to show the photo full (defaults to NO)
browser.enableGrid = YES; // Whether to allow the viewing of all the photo thumbnails on a grid (defaults to YES)
browser.startOnGrid = NO; // Whether to start on the grid of thumbnails instead of the first photo (defaults to NO)
browser.autoPlayOnAppear = NO; // Auto-play first video

// Customise selection images to change colours if required
browser.customImageSelectedIconName = @"ImageSelected.png";
browser.customImageSelectedSmallIconName = @"ImageSelectedSmall.png";

// Optionally set the current visible photo before displaying
[browser setCurrentPhotoIndex:1];

// Present
[self.navigationController pushViewController:browser animated:YES];

// Manipulate
[browser showNextPhotoAnimated:YES];
[browser showPreviousPhotoAnimated:YES];
[browser setCurrentPhotoIndex:10];

Then respond to the required delegate methods:

- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
    return self.photos.count;
}

- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
    if (index < self.photos.count) {
        return [self.photos objectAtIndex:index];
    }
    return nil;
}

You can present the browser modally simply by wrapping it in a new navigation controller and presenting that. The demo app allows you to toggle between the two presentation types.

Videos

You can represent videos in MWPhoto objects by providing a standard MWPhoto image object with a videoURL. You can also use a PHAsset object or a URL to an assets library video.

// Video with URL including poster photo
MWPhoto *video = [MWPhoto photoWithURL:[NSURL URLWithString:@"https://scontent.cdninstagram.com/hphotos-xpt1/t51.2885-15/e15/11192696_824079697688618_1761661_n.jpg"]];
video.videoURL = [NSURL URLWithString:@"https://scontent.cdninstagram.com/hphotos-xpa1/t50.2886-16/11200303_1440130956287424_1714699187_n.mp4"];

// Video with PHAsset
MWPhoto *video = [MWPhoto photoWithAsset:asset targetSize:[UIScreen mainScreen].bounds.size]; // Example sizing

// Video with ALAsset
MWPhoto *video = [MWPhoto photoWithURL:asset.defaultRepresentation.url];
if ([asset valueForProperty:ALAssetPropertyType] == ALAssetTypeVideo) {
    photo.videoURL = asset.defaultRepresentation.url;
}

// Video with no poster photo
MWPhoto *video = [MWPhoto videoWithURL:[NSURL URLWithString:@"https://scontent.cdninstagram.com/hphotos-xfa1/t50.2886-16/11237510_945154435524423_2137519922_n.mp4"]];

// Video grid thumbnail
MWPhoto *videoThumb = [MWPhoto photoWithURL:[NSURL URLWithString:@"https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s150x150/e15/11240463_963135443745570_1519872157_n.jpg"]];
videoThumb.isVideo = YES;

// Video grid thumbnail for video with no poster photo
MWPhoto *videoThumb = [MWPhoto new];
videoThumb.isVideo = YES;

Grid

In order to properly show the grid of thumbnails, you must ensure the property enableGrid is set to YES, and implement the following delegate method:

- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser thumbPhotoAtIndex:(NSUInteger)index;

The photo browser can also start on the grid by enabling the startOnGrid property.

Actions

By default, if the action button is visible then the image (and caption if it exists) are sent to a UIActivityViewController.

You can provide a custom action by implementing the following delegate method:

- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser actionButtonPressedForPhotoAtIndex:(NSUInteger)index {
    // Do your thing!
}

Photo Captions

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

MWPhoto *photo = [MWPhoto photoWithURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3629/3339128908_7aecabc34b.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 MWPhoto for your photos so you can store more data than a simple caption string.
  2. Subclass MWCaptionView 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 MWCaptionView.h
  3. Implement the -photoBrowser:captionViewForPhotoAtIndex: MWPhotoBrowser delegate method (shown below).

Example delegate method for custom caption view:

- (MWCaptionView *)photoBrowser:(MWPhotoBrowser *)photoBrowser captionViewForPhotoAtIndex:(NSUInteger)index {
    MWPhoto *photo = [self.photos objectAtIndex:index];
    MyMWCaptionViewSubclass *captionView = [[MyMWCaptionViewSubclass alloc] initWithPhoto:photo];
    return captionView;
}

Selections

The photo browser can display check boxes allowing the user to select one or more of the photos. To use this feature, simply enable the displaySelectionButtons property, and implement the following delegate methods:

- (BOOL)photoBrowser:(MWPhotoBrowser *)photoBrowser isPhotoSelectedAtIndex:(NSUInteger)index {
    return [[_selections objectAtIndex:index] boolValue];
}

- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index selectedChanged:(BOOL)selected {
    [_selections replaceObjectAtIndex:index withObject:[NSNumber numberWithBool:selected]];
}

Installation

MWPhotoBrowser is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "MWPhotoBrowser"

Usage

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

Then import the photo browser into your source files (or into your bridging header if you're using with Swift and not using frameworks with Cocoapods):

#import "MWPhotoBrowser.h"

If you are using Swift and frameworks, then you can just import the browser into your Swift source file:

import MWPhotoBrowser

Author

Michael Waterfall, [email protected]

License

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

Notes

Demo photos kindly provided by Oliver Waters.

mwphotobrowser's People

Contributors

dchohfi avatar deepfriedtwinkie avatar mwaterfall avatar ninjinkun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mwphotobrowser's Issues

Compile error when building MWPhotoBrowser project

Downloaded the MWPhotoBrowser project and wanted to build to get the libMWPhotoBrowser.a file for one of my projects.. however the compiler list a load of problems preventing a build e.g.:

Use of undeclared identifier 'UIBarMetricsDefault'; did you mean 'UIBarStyleDefault'? MWPhotoBrowser.me

I think that most of the 34 issue are similar/related to this.. any idea what I am doing wrong..

Am on 10.6.8 and xcode 4.0.2 (yes I now I should upgrade but is the reason)

ObjectAtIndex beyond bounds

Hi Michael, thanks for nice controls. I am using two delegate methods below which feed the MWPhotoBrowser with NSMutableArray:

pragma mark - MWPhotoBrowserDelegate

  • (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
    return _photos.count;
    }
  • (MWPhoto *)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
    if (index < _photos.count)
    return [_photos objectAtIndex:index];
    return nil;
    }

For creating the array, I use this with a while loop:

            MWPhoto *mwPhoto = [[MWPhoto alloc] initWithURL:[NSURL URLWithString:@"http:/test.com/test1.jpg"]];
            mwPhoto.caption = [NSString stringWithFormat:@"%@ - %@", @"Test 1", @"Test 2"];
            [appDelegate.photosArray addObject:mwPhoto];
            [mwPhoto release];

Then for launching MWPhotoBrowser:

MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
browser.displayActionButton = YES;

[browser setInitialPageIndex:appDelegate.selectedPhotoId];
browser.photoGroup = appDelegate.selectedPhotoSite;

self.photos = appDelegate.photosArray;

UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:browser];
nc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:nc animated:YES];
[nc release];

[browser release];

I am getting following error on MWPhotoBrowser.m:

  • (void)didStartViewingPageAtIndex:(NSUInteger)index {

    // Release images further away than +/-1
    NSUInteger i;
    if (index > 0) {
    // Release anything < index - 1
    NSLog(@"Index: %d", index);
    for (i = 0; i < index-1; i++) {
    --> id photo = [_photos objectAtIndex:i];

* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM objectAtIndex:]: index 20 beyond bounds [0 .. 19]'

When I changed the delegate method to:

  • (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
    return _photos.count-1;
    }

it works, but as obvious I can't browse the last picture in the array. Can you help me out? I am not sure why it goes out of bounds?

Thanks,
Abdullah

Photo not showing up, action button has no result.

When I implement MWPhotoBrowser into my project (it appears modally), and after I load in the images (as UIImages), the images do not appear in the view, and the action button when pressed has no response.

The captions are present, but the photos are not.

Some things to point out: I am using MWPhotoBrowser in a project that uses a stacked layout controller (https://github.com/steipete/PSStackedView), could this be causing a problem?

Thanks

Transparent navbar when back to previous view.

Hello !

First of all, let me congratulate you for your code, it is exactly what I have been looking for and this is really working well ! Great job !

I just encounter an issue :
When I come back to my initial view (a tableview in my case), the whole view (which was suppose to start under the navBar) is now behind the tabBar with it being halfly transparent.

Do you have any idea about the problem ?

Many thanks and great job !

Only show the first photo when add MWPhotoBrowser as subview

I've created the MWPhotoBrowser object in my viewcontroller as a subview from my self.view:

For 1 to 3
{
[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3590/3329114220_5fbc5bc92b_b.jpg"]]];
}

self.photos = photos;

MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];

browser.displayActionButton = NO;
browser.wantsFullScreenLayout = NO;

[self.view addSubview:browser.view];
[self.view bringSubviewToFront:browser.view];

and, so, only show me the first image, but the scroller works fine for the three images. However if I define the MWPhotoBrowser object so:

[self.navigationController pushViewController:browser animated:YES];

The browser show me correctly the three images.

And idea how to fix it with the first method?

Sorry for my english and congratulations for this project. Thanks a lot

Issue in landscape mode

I tried your photo browser, very nice work but i have an issue... when passing to landscape mode it seems that zoom factor is less than in portrait mode.... when passing to landscape, image is not centered too, and allow to pan it up outside the screen (without zoom)...

Thanks a lot

Cancel background loading

Hey there,

When I load several MWPhoto's in the background (obtainInBackgroundAndNotify method) it does the obvious; load the image in the background. Is there a simple way to cancel the loading?

An example:

We have a TableviewController with a UITableView (albumTable) which get pushed on the navigation stack from some other ViewController. The albumTable gets its data from an array (photoArray) filled with MWPhoto's (singlePhoto). Each cell in the albumTable shows one singlePhoto from the photoArray. But beforehand we tell all the singlePhoto's in the photoArray to obtain the image in the background so the albumTable can reload each cell when the image is loaded. This is done by calling the method: [makeObjectsPerformSelector:@selector(obtainImageInBackgroundAndNotify:) withObject:self].

Assume all works well. When we pop the TableviewController from the navigation stack, the singlePhoto's are still loading their respective images in the background.

Looking at the example; when we pop the TableviewController, the singlePhoto's ought to cancel or otherwise stop the loading. Is there an easy way to implement this one?

Thanks in advance,

Gerald

Large images cause crash on Device

When I load "lots" of large (>=2MP) images the viewer occasionally crashes due to low memory.

To test it I added these pictures to the flickr part of the demo.

            [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://1.bp.blogspot.com/--LtN-73xjcw/T3EAnNauZsI/AAAAAAAAAIk/fczGILxBxHw/s1600/ireland2.jpg"]]];
            [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://2.bp.blogspot.com/-zrVPELY19zY/T3EAo0lp35I/AAAAAAAAAIs/lJrCTsehBJw/s1600/ireland_philmack.jpg"]]];
            [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://2.bp.blogspot.com/-kvJ60qvw-_Q/T3EA0ARbtiI/AAAAAAAAAI0/58bcB8Drz-Q/s1600/Dunguaire-Castle-Kinvara-County-Clare-Ireland.jpg"]]];
            [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://www.wallpapers-free.co.uk/backgrounds/nature/beaches_and_coasts/Copy-1-of-Sunset-Across-Lower-Lough-Erne-Fermanagh-Ireland.jpg"]]];
            [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://1.bp.blogspot.com/_SZpkjg0HXck/SxLlR-hl3iI/AAAAAAAAADA/5_wxb_AxyVk/s1600/Ireland+2009+229.JPG"]]];
            [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"https://upload.wikimedia.org/wikipedia/commons/e/e6/Bingley_Ireland_Bridge_1.jpg"]]];
            [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://fc03.deviantart.net/fs30/f/2008/059/7/5/Typical_Ireland_Landscape_by_peterwadson.jpg"]]];
            [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://bestfreewallpapers.info/Ireland%20Wallpapers%20%5B1920x1440%5D%20HD%20Collection/Clifden%20Castle,%20County%20Galway,%20Ireland.jpg"]]];
            [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://www.wallpapers-free.co.uk/backgrounds/animals/horses/Wicklow-Countryside-Near-Powerscourt-Castle-Ireland.jpg"]]];
            [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://onlyhdwallpapers.com/wallpaper/lough_key_forest_park_ireland_1600x1200_id_desktop_wallpaper-309617.jpg"]]];
            [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"https://aishagrace.files.wordpress.com/2009/07/04ballintoy-northern-ireland.jpg"]]];
            [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"https://woonsocketlibrary.files.wordpress.com/2011/03/celebrating_ireland.jpg"]]];
            [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://www.atpm.com/15.08/travels/images/Ireland%20-%20Ruins%20Off%20the%20Coast%20of%20Dalkey.jpg"]]];

I am testing using an iPhone 3GS. I had a look in Instruments and the app's memory consumption is steadily increasing with every image. In comparison the Photos app is steady in it's memory consumption.

Feature request: queued downloading

This photobrowser is fantastic. A feature request: Rather than downloading all three adjacent (current, previous, next) images in parallel from url requests, starting with (only) the one on screen and then serially proceeding to the next two adjacent ones would really speed apparent responsiveness of the app. I'll try to do this myself if I have time, but I figure others would be able to do it faster and easier... Thanks!

MWPhotoBrowser not stopping current downloads when dismissed

I've noticed that started (and not yet finished) downloads are not stopped when the view is dismissed !
I solved this in my case by adding this in - (void)doneButtonPressed:(id)sender (MWPhotoBrowser.m)

for (id p in _photos)
{
    if (p != [NSNull null])
    {
        // Cancel requests
        [[SDWebImageManager sharedManager] cancelForDelegate:p];
    }
}

But I think that there is certainly a more optimized way to do this ...

Crash when zooming and slide image for fast

I found bug that will crash when zooming image and slide image to next image for fast

below is error that produced from xCode log window

PhotoBrowserDemo[448:707] * Terminating app due to uncaught exception 'NSGenericException', reason: '* Collection <__NSCFSet: 0x1458b0> was mutated while being enumerated.

found error in MWPhotoBrowser.m line:659

Possible memory leak with panning and zooming

Hi,

Thanks for creating this fantastic library. I was playing around creating a custom caption class - awesomely easy by the way when I ran the 'Leaks' tool. When panning and zooming on a photo I was getting a few leaks reported in the UIGestureRecogniser as I haven't touched any of this code and I could reproduce the leaks on my root branch (without any of my changes) I thought I would let you know!

I might try to see if I can figure out what is up, but as a noob I fully expect you to do a better job - I might be mis-using the tool and there isn't a leak anyway!

I was using your demo code on the simulator and could trigger the leaks on all 3 table entries as well as with either modal/push. Although exactly which gesture caused the problem seemed to change - I saw it trigger after a zoom out and zoom in and a pan, I also saw each of these execute without issue!

Thanks again and let me know how I can help further

Alison

Display images from documents directory

I am trying to take picture using camera and save the image to the documents directory. I am able to save the image to directory and also able to read it from the directory but not able to display the image.
Below code to get the documents directory path and image.

NSArray *searchPaths =
NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
_documentsPath = [searchPaths objectAtIndex: 0];
[_documentsPath retain];
// NSLog(@"Files in the documents Directory %@", _documentsPath);
filenames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:_documentsPath error: NULL];
NSString *filename = [filenames objectAtIndex:0];
NSLog(@"files in documents Directory %@", filename);

Now the image that I get I want to pass it to Photos NSMutable array. Can anyone please assist to me achieve this? I will really appreciate it.

case 0:
[photos addObject:[MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"photo2l" ofType:@"jpg"]]];

Thank you very much.
Rahul-

Please add semantic version tags.

I’ve recently added MWPhotoBrowser to the CocoaPods package manager repo.

CocoaPods is a tool for managing dependencies for OSX and iOS Xcode projects and provides a central repository for iOS/OSX libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.

However, MWPhotoBrowser doesn't have any version tags. I’ve added the current HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.

Semantic version tags (instead of plain commit hashes/revisions) allow for resolution of cross-dependencies.

In case you didn’t know this yet; you can tag the current HEAD as, for instance, version 1.0.0, like so:

$ git tag -a 1.0.0 -m "Tag release 1.0.0"
$ git push --tags

Statusbar and Navigation Bar are not correct

I've got an application with a customized navigation bar, style and tint have been updated.

The "menu" pushes to the stack the MWPhotoBrower view. When it is popped off, the status bar and navigation bar of the view that pushed the MWPhotoBrowser is not restored to its original state.

The tableview on the calling view is now starting at 0,0 instead of after the statusbar + navigation bar.

photoAtIndex fired weirdly..

Hi ..
I noticed that photoAtIndex delegate fired twice in first time .. after that it behaves strange when scrolling between photos : not fired at all at the last and first photo !! is this normal ??? and how to detect the index of viewed photos accurately ..

thank very much .

Navigation Bar offset on iPad

Concerning this issue which was previously opened and closed:

#16

I'm currently also experiencing the part that reads:

"One Involves pushing MWPhotoBrowser against the navigational controller of my detail view. The works for the most part, except that (1) It is not fullscreen and (2) When I do enter the MWPhotoBrowser, and the top NavBar fades away, it will come back offset from it's original y-coordinate. Looks like it is doing it by the approximate dimension of a Status Bar."

So, I'm not concerned about the not being full screen part, but the navigation bar being pushed down (by the seemingly exact height of the status bar) is really stumping me. Has anyone solved this when using split view controller?

scrollViewDidScroll being called when rotating photobrowser

Whenever I'm running with an array of images (I've got them downloaded earlier, so I don't use the SD classes), when at the final image and rotate the view, the method scrollViewDidScroll is called, and shifts the current image over two. I've run in the simulator and the device and both have the same issue. The demo doesn't do it, but my version does. No changes have been made except for removing the downloader references.

Gives linker error for MKAnnotationView+WebCache

Hi,
I have updated MWPhotoBrowser which I am using in my app with the latest one assuming that the crash while viewing images in the library due to large image size has been fixed in this version. However, I am getting a linker error for MKAnnotationView+WebCache class whose details are as follows:

Undefined symbols for architecture i386:
"OBJC_CLASS$MKAnnotationView", referenced from:
l_OBJC
$CATEGORY_MKAnnotationView$_WebCache in MKAnnotationView+WebCache.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'll be grateful if you could help me out with this. I have used Method 2 to use this project in mine i.e. included all classes and libraries and not the project in my app.

Thanks a ton!

MWPhotoBrowser display image incorrectly when the start page index is not from 0

There are statements that make this issue:

MWPhotoBrowser *photoBrowser = [[MWPhotoBrowser alloc] initWithPhotos:self.images];
[photoBrowser setInitialPageIndex:index]; // index can be  any digital number. [index >= 0]
[[self navigationController] pushViewController:photoBrowser animated:YES];

The statement cause this issue may be located in function -(void)tilePages;
Below code is the root cause:

[visiblePages addObject:page];
[pagingScrollView addSubview:page];

It appears that when visiblePages is nil, still attempt to add subview to pagingScrollView.

MWPhotoBrowser Zoom In Level

Hi Michael! Thank you for your hard work creating this AMAZING Photo Gallery.

I love the functionality and feel of it.

I'm developing my first iOS App using your awesome library.

However, I would like to know how I can adjust the ZOOM IN on doubleTap.

I played around with:

[self zoomToRect:CGRectMake(touchPoint.x, touchPoint.y, 1, 1) animated:YES];

inside the MWZoomingScroolView.m but I couldn't figure it out.

Thanks in advance.

How to display one photo at a time as needed

First of all thank you very much for your time and effort in creating this nice library. I have a question on maybe to enhance the browsing usability as a photo gets downloaded through an http request.

In the demo, you are loading 4 photos all at once. This works for a small list of photos with relatively small sized images. But, I was wondering how you would go about implementing loading one photo at a time based on a list of let's say 2,000 images that one would like to browse through. So, I'm looking at a way to download this list of URL strings and then download the next photo as the user swipes to the left for the next one to be displayed.

Not sure if this makes sense; but, any pointers on where to implement this in the demo would be great. Thanks again for your help.

getting the current image in scrollview

Hello
It would be nice to have a method which will return the currently showing image on scrollview
I've tried some way to manipulate it (You can see it in below) but no luck because as far as I understand when I check the current underlying image property its returning the next image(according to direction of scrolling)

This is the method I've added to MWPhoto class:

-(UIImage*) getImagePtr
{
return self.underlyingImage;
}

This is the mwphotobrowser delegate:

-(MWPhoto*)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index
{
if (index < [self.photos count]) {
MWPhoto *currentPhoto = [self.photos objectAtIndex:index];
currentNoteImage = currentPhoto.getImagePtr;
return currentPhoto;
}
return nil;
}

Is there an easy way to integrate a title for each photo?

Hi Michael,

Is there an easy way to integrate a title for each photo, like in the facebook app? or is it something you are planning to add?

Another thing is that, when I added MWPhotoBrowser to my project, there were a few irregularities (I can't see those in your project but I couldn't figure out why they are in my app)

  1. After single tap, the navigationBar disappears (as it should). but when it appears again, it appears with a gap of 20 px between the status bar the navBar
  2. The status bar disappears but the space just becomes plain white.

Thanks and regards,
Ashish.

bug - MWPhoto not deallocated / released

Hi,
first of all many thanks for your cool job.
Now let me share a bug i found out using your nice photo-gallery:
when i load a browser with some MWPhoto(s) (from remote url, in my case), let's say 10 photos, and then i go out and release the browser i just automatically release 9 photos, and the one that was shown to the user still live somewhere...

i fixed it adding 1 line of code in dealloc method of MWZoomingScrollView class:

-(void)dealloc {

self.captionView = nil; // needed HERE: bug!!!

...

}

tks again,
luca

Nav bar and status bar issues when pushing browser from complex view hierarchy

I'm certain this problem must be specific to my setup, because on your demo it works perfectly. I really hope you can give me a hand to fix this because your photo browser is a key part of my app and I wouldn't like to use another one.

Let me show you some screenshots of what's going on:

http://imgur.com/a/U35CH#0

i'm pretty sure it must be something with my view controller hierarchy: I'm using ZUUIRevealController (https://github.com/pkluz/ZUUIRevealController) and the "Gallery" view you see on the imgs is setup as the front view. Your photo browser is pushed into the navigation stack from that Gallery view controller (which is the ZUUIRevealController's front view controller), and when the controls hide, the navigation bar is off place, and if I go back to the previous controller, the status bar continues to hide by itself... any info you need just let me know!!

Thanks again for the great work!

Recommended Usage on an iPad

Hey Everyone

Currently working on a universal application (iPhone and iPad) and using the MWPhotoBrowser on the iPhone version. I love it. Now I am trying to use this in the iPad as well, and was curious as to others peoples experience with MWPhotoBrowser in an iPad running application.

I am wondering what the best way of doing this in an iPad implementation would be? My iPad app is using a split view controller, and (ideally) clicking one of my image thumbnails would open the MWPhotoBrowser full screen. I am trying two approaches:

  • One Involves pushing MWPhotoBrowser against the navigational controller of my detail view. The works for the most part, except that (1) It is not fullscreen and (2) When I do enter the MWPhotoBrowser, and the top NavBar fades away, it will come back offset from it's original y-coordinate. Looks like it is doing it by the approximate dimension of a Status Bar.
  • My other approach (which I have only just started looking @, involves modal controllers. I will admit that I am rather new to Modal Controllers (having barely used them to this point) but the idea of pushing a view to fullscreen does look promising. I would need to add controls to dismiss the browser (pushing the MWPhotoBrowser modally prevents me going back).

Now, I'm hoping someone has encountered a similar need, and could give me some guiding words on how best to Proceed. Not asking for someone to do it for me (how will I learn otherwise?). More asking for advice on how best to proceed.

Thanking any contributors in advance!

Problem with MWPhotoBrowser and UIWebView

Hi,

I really like MWPhotoBrowser, but i have one problem:

I create the photos with the photoWithURL: method. I also have an UIWebView in my application. The problem appears, as soon as a scroll quick through the photos: Instead of some photos, the activity indicator appears and the photos must be reload. When I remove the UIWebView, everything works fine.
You can try this very easy, just create in the Menu class of the demo project a UIWebView.

Sorry, but my english is not so good.

Thanks,
Mikkell

it doesnt zoom when i use mwphotobrowser with uitabbarcontroller

hi, its a nice photobrowser. but i have a problem

my app has a uitabbarcontroller. there is a navigation controller in the first tab. and navigation bar is hidden.
when tap a button, i call your photobrowser.
zooming works good with similator, 3g, ipod,
but it doesnt work on iphone 4 device.
it doesnt do anything when i double tap or pinch.

if i install your sample to iphone4, it works good.
its weird problem...
everything is same with my app, just tabbarcontroller is different.

can you checkt it?

Help Sub Classing Caption View

I need some help subclassing the caption view. I'm new at programming for iOS so it is probably something easy. This is my code for calling the custom view

  • (MWCaptionView *)photoBrowser:(MWPhotoBrowser *)photoBrowser captionViewForPhotoAtIndex:(NSUInteger)index {
    NSLog(@"%@", [[self.photos objectAtIndex:index] caption]);
    CustomCaptionView *ccv = [[CustomCaptionView alloc] initWithPhoto:[self.photos objectAtIndex:index]];
    return ccv;
    }

The problem is my CustomCaptionView _photos isn't getting the information. Can someone help me please?

could you please provide any suggestion on display videos like the Photo app?

this project helped me a lot and saved me tons of time, thanks a lot, and this is much better than Three20!!

i got a problem here, is there any way to display videos like the native Photo app does in the scrollview?

I just need some suggestions, you don't have to provide me sample code. wish i could get some ideas for this, because i am stucked at this for a weeks already.

thanks

Adding to the toolbar

What is the best way to add to the toolbar. I like how you can change the MWCaptionView. Can you add something like that for the toolbar or do I just need to subclass MWPhotoBrowser to do it. What I want to do is add a button to add to favorites.

Memory leak with ARC

Hi, i've adapted this for use with a program using ARC for ios5 with Xcode 4.2. This causes a memory leak somewhere (i haven't looked too deeply into it, its a bit puzzling). But looking at instruments i noticed 2 things

  1. Memory used is huge? why is this? a 5mb image when loaded is 70mb almost, is this the decompressed data? any reason to do it this way?
  2. ARC doesn't release any of that data when changing all [object release] to object = nil;, something's leaking but not showing up as a leak, so loading an image then going back retains the 70mb in memory, doubling when loading it again

The only solution i've found so far is just specifying -fno-objc-arc for each file, which works, but i'd still like to address a 5mb image taking 70mb in memory...

Crashing when loading very large photos

MWPhotoBrowser keeps crushing if I use it to open more than 30 or 40 files, each of which is about the size of 2~3M. A few of them are 5M

I did see "Received memory warning." Then app crushes but XCode did not show me which _cmd caused the crushing.

I tried to call releaseAllUnderlyingPhotos before it got "Received memory warning." But that did not help.

And idea how to fix it ?

Update: sometime when I use it to open a picture of size 5M, it will just crush too.

Getting the path or URL of currently showing photo

Hi,
I've been playing with this great library - thank you for creating it.
I've needed to be able to report the URL for the currently showing photo and I've been able to do it upgrading the photoURL ivar to a property on a MWPhoto class object.... but this requires me to change two lines of code in your lib.

Can you think of a better way for me to do this, or can you add the ability to access the 'root' of a photo?

Thanks so much.

Alison

Updated version of SDWebImage

Can you please update the version of SDWebImage included in MWPhotoBrowser to the lastest one?

I was trying to use one of their categories with blocks and was getting unrecognized selector sent error and found out that MWPhotoBrowser included the old version of SDWebImage.

Thanks.

next and previous buttons are missing

Thanks Michael for all your excellent work on this great library:) I'm using today's build from ~ three hours ago. Seems the next and previous buttons are missing when scrolling through the images. Same for the action button, no image for that one either.

I'm targeting ios5 using the "-fno-objc-arc" compiler setting

underlyingImage Crash

I'm adding the MWPhotobrowser to my project using urls to files on the device. When I push the view controller I get the following error:

-[__NSCFDictionary underlyingImage]: unrecognized selector sent to instance 0xce034f0
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary underlyingImage]: unrecognized selector sent to instance 0xce034f0'
*** First throw call stack:
(0x16bd052 0x198fd0a 0x16beced 0x1623f00 0x1623ce2 0x7a007 0x80897 0x806b9 0x7b398 0x7a9ed 0x78085 0x79a20 0x7751f 0x7c964e 0x7c9941 0x7db47d 0x7db66f 0x7db93b 0x7dc3df 0x7dc561 0x8f84ca 0x742301 0x16bee72 0x62292d 0x62c827 0x5b2fa7 0x5b4ea6 0x5b4580 0x16919ce 0x1628670 0x15f44f6 0x15f3db4 0x15f3ccb 0x2438879 0x243893e 0x703a9b 0x2bb0 0x23d5 0x1)
terminate called throwing an exception(lldb)

I should add that this project uses ARC, but I have disabled ARC for this library as well as SDWebImage using the appropriate compiler flag.

Any suggestions?

Very Slow Animating between Actual Photos

The PhotoBrowser has very poor performance when I'm loading images that have1-2mb in size.

Try adding some larger photos and then browsing. It will be very slow. Removing the decompression line will help some, but it's still much slower than my own implementation that just loads the files.

-Paul Solt

browser zoom works on simulator and 3gs but not on 4s

Hi and thanks for the wonderful photo browser,

I am having a problem with zooming: it works perfectly on simulator and an iphone 3gs but not on an iphone 4s.
Tried to dig into the code but didn't find any clue.
Any hint?

Thanks again,
Matteo

u rocks!!!

man ure the best, i spend the all day trying to do a photo browser like this one with the sample code given by apple, but nothing compares to this, so easy to implement and works like a champ... thanks a lot

Placeholder for MWPhotoBrowser

Is there a method implemented already for custom placeholder?

custom placeholder means before loading "full size" image, I want it to display thumbnail images first until full size image loaded

How to not cache images?

I would like to not have images cached on the phone since this behavior messes with the updated content. How would I achieve either not caching the images at all or clear the photo browser cache when the app closes?

Thank you!

Can not run Demo in XCode 4.2

I just downloaded the latest version as of January 31st, 2012 and trying to run the Demo without success. I'm building in XCode v4.2 with iOS 5.0 as target with success but it just doesn't want to run in either the iPhone Simulator or on my iPhone 4S.

Am I doing something wrong?

Thanks,
Thomas

can't import MWPhotoBrowser

i can't import MWPhotoBrowser into my current project, I am using "Method 2: Including Source Directly Into Your Project"
But the app crashed after launched, there is no error message at all. I did disabled all ARC for the files in MWPhotoBrowser. any idea?

crush on idevice with no mail account

I found a bug: when display an image and the current device hasn't a valid email account configured, it displays 2 menu items correctly: "save,copy"
If you don't want one of these and tap to another point into the screen, that causes a crash (the buttonIndex is 2).

So you can fix it whit this code:

  • (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
    if (actionSheet == _actionsSheet) {
    NSLog(@"%d - %d",buttonIndex,actionSheet.firstOtherButtonIndex);
    self.actionsSheet = nil;
    if (buttonIndex == actionSheet.firstOtherButtonIndex) {
    [self savePhoto]; return;
    } else if (buttonIndex == actionSheet.firstOtherButtonIndex + 1) {
    [self copyPhoto]; return;
    } else if (buttonIndex == actionSheet.firstOtherButtonIndex + 2 && [MFMailComposeViewController canSendMail]) {
    [self emailPhoto]; return;
    }
    }
    [self hideControlsAfterDelay]; // Continue as normal...
    }

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.