MWPhotoBrowser, simple and elegant image library for iOS
When it’s necessary a gallery within an app for iOS, we can find already developed several solutions that can help us in the project. After studying various options, from Sixtemia we recommend the solution developed by Michael Waterfall (Milton Keynes, UK) MWPhotoBrowser.
The strengths of the library are:
- Easy to integrate in our project.
- Updated to iOS7.
- Load images with local or remote with cache.
- Ability to show a picture text label.
- Selection of images and touch to capture the image.
- Share options.
Below is an example of how to integrate the library:
// Create array of MWPhoto objects
self.photos=[NSMutableArrayarray];
[photos addObject:[MWPhoto photoWithURL:[NSURL fileURLWithPath:[[NSBundlemainBundle] 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"]]];
// Create browser (must be done each time photo browser is
// displayed. Photo browser objects cannot be re-used)
MWPhotoBrowser*browser=[[MWPhotoBrowseralloc] 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.wantsFullScreenLayout=YES;// iOS 5 & 6 only: Decide if you want the photo browser full screen, i.e. whether the status bar is affected (defaults to YES)
// 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];
The library is based on two methods of its delegate to assign images to the gallery:
|
-
(
NSUInteger
)
numberOfPhotosInPhotoBrowser
:
(
MWPhotoBrowser
*
)
photoBrowser
-
(
id
MWPhoto
)
photoBrowser
:
(
MWPhotoBrowser
*
)
photoBrowser
photoAtIndex
:
(
NSUInteger
)
index
|