{"id":1477,"url":"https://github.com/mwaterfall/MWPhotoBrowser","last_synced_at":"2025-08-02T04:31:44.285Z","repository":{"id":1134877,"uuid":"1012503","full_name":"mwaterfall/MWPhotoBrowser","owner":"mwaterfall","description":"A simple iOS photo and video browser with grid view, captions and selections.","archived":false,"fork":false,"pushed_at":"2024-06-27T12:38:19.000Z","size":21737,"stargazers_count":8755,"open_issues_count":335,"forks_count":2700,"subscribers_count":297,"default_branch":"master","last_synced_at":"2025-07-26T11:56:30.556Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mwaterfall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-10-21T15:40:47.000Z","updated_at":"2025-07-17T20:08:23.000Z","dependencies_parsed_at":"2022-07-06T08:31:21.103Z","dependency_job_id":"abe05cb9-2beb-407d-9a6f-45f11e6569b1","html_url":"https://github.com/mwaterfall/MWPhotoBrowser","commit_stats":{"total_commits":180,"total_committers":6,"mean_commits":30.0,"dds":0.07222222222222219,"last_synced_commit":"66ddd73859978a9c24c6ce014634f3bde351e917"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/mwaterfall/MWPhotoBrowser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwaterfall%2FMWPhotoBrowser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwaterfall%2FMWPhotoBrowser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwaterfall%2FMWPhotoBrowser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwaterfall%2FMWPhotoBrowser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mwaterfall","download_url":"https://codeload.github.com/mwaterfall/MWPhotoBrowser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwaterfall%2FMWPhotoBrowser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268240279,"owners_count":24218355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:15:47.370Z","updated_at":"2025-08-02T04:31:43.244Z","avatar_url":"https://github.com/mwaterfall.png","language":"Objective-C","readme":"# MWPhotoBrowser\n\n\u003c!--[![CI Status](http://img.shields.io/travis/Michael Waterfall/MWPhotoBrowser.svg?style=flat)](https://travis-ci.org/Michael Waterfall/MWPhotoBrowser)--\u003e\n[![Version](https://img.shields.io/cocoapods/v/MWPhotoBrowser.svg?style=flat)](http://cocoapods.org/pods/MWPhotoBrowser)\n[![License](https://img.shields.io/cocoapods/l/MWPhotoBrowser.svg?style=flat)](http://cocoapods.org/pods/MWPhotoBrowser)\n[![Platform](https://img.shields.io/cocoapods/p/MWPhotoBrowser.svg?style=flat)](http://cocoapods.org/pods/MWPhotoBrowser)\n\n[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=mwaterfall\u0026url=https://github.com/mwaterfall/MWPhotoBrowser\u0026title=MWPhotoBrowser\u0026language=\u0026tags=github\u0026category=software)\n\n## A simple iOS photo and video browser with optional grid view, captions and selections.\n\nMWPhotoBrowser 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.\n\nThe browser can also be used to allow the user to select one or more photos using either the grid or main image view.\n\n[![Alt][screenshot1_thumb]][screenshot1]    [![Alt][screenshot2_thumb]][screenshot2]    [![Alt][screenshot3_thumb]][screenshot3]    [![Alt][screenshot4_thumb]][screenshot4]    [![Alt][screenshot5_thumb]][screenshot5]    [![Alt][screenshot6_thumb]][screenshot6]\n\n[screenshot1_thumb]: https://raw.github.com/mwaterfall/MWPhotoBrowser/master/Screenshots/MWPhotoBrowser1t.png\n[screenshot1]: https://raw.github.com/mwaterfall/MWPhotoBrowser/master/Screenshots/MWPhotoBrowser1.png\n[screenshot2_thumb]: https://raw.github.com/mwaterfall/MWPhotoBrowser/master/Screenshots/MWPhotoBrowser2t.png\n[screenshot2]: https://raw.github.com/mwaterfall/MWPhotoBrowser/master/Screenshots/MWPhotoBrowser2.png\n[screenshot3_thumb]: https://raw.github.com/mwaterfall/MWPhotoBrowser/master/Screenshots/MWPhotoBrowser3t.png\n[screenshot3]: https://raw.github.com/mwaterfall/MWPhotoBrowser/master/Screenshots/MWPhotoBrowser3.png\n[screenshot4_thumb]: https://raw.github.com/mwaterfall/MWPhotoBrowser/master/Screenshots/MWPhotoBrowser4t.png\n[screenshot4]: https://raw.github.com/mwaterfall/MWPhotoBrowser/master/Screenshots/MWPhotoBrowser4.png\n[screenshot5_thumb]: https://raw.github.com/mwaterfall/MWPhotoBrowser/master/Screenshots/MWPhotoBrowser5t.png\n[screenshot5]: https://raw.github.com/mwaterfall/MWPhotoBrowser/master/Screenshots/MWPhotoBrowser5.png\n[screenshot6_thumb]: https://raw.github.com/mwaterfall/MWPhotoBrowser/master/Screenshots/MWPhotoBrowser6t.png\n[screenshot6]: https://raw.github.com/mwaterfall/MWPhotoBrowser/master/Screenshots/MWPhotoBrowser6.png\n\nWorks on iOS 7+. All strings are localisable so they can be used in apps that support multiple languages.\n\n## Usage\n\nMWPhotoBrowser 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.\n\n`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`.\n\nSee the code snippet below for an example of how to implement the photo browser. There is also a simple demo app within the project.\n\n```obj-c\n// Create array of MWPhoto objects\nself.photos = [NSMutableArray array];\n\n// Add photos\n[photos addObject:[MWPhoto photoWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@\"photo2l\" ofType:@\"jpg\"]]]];\n[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@\"http://farm4.static.flickr.com/3629/3339128908_7aecabc34b.jpg\"]]];\n[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@\"http://farm4.static.flickr.com/3590/3329114220_5fbc5bc92b.jpg\"]]];\n\n// Add video with poster photo\nMWPhoto *video = [MWPhoto photoWithURL:[NSURL URLWithString:@\"https://scontent.cdninstagram.com/hphotos-xpt1/t51.2885-15/e15/11192696_824079697688618_1761661_n.jpg\"]];\nvideo.videoURL = [[NSURL alloc] initWithString:@\"https://scontent.cdninstagram.com/hphotos-xpa1/t50.2886-16/11200303_1440130956287424_1714699187_n.mp4\"];\n[photos addObject:video];\n\n// Create browser (must be done each time photo browser is\n// displayed. Photo browser objects cannot be re-used)\nMWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];\n\n// Set options\nbrowser.displayActionButton = YES; // Show action button to allow sharing, copying, etc (defaults to YES)\nbrowser.displayNavArrows = NO; // Whether to display left and right nav arrows on toolbar (defaults to NO)\nbrowser.displaySelectionButtons = NO; // Whether selection buttons are shown on each image (defaults to NO)\nbrowser.zoomPhotosToFill = YES; // Images that almost fill the screen will be initially zoomed to fill (defaults to YES)\nbrowser.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)\nbrowser.enableGrid = YES; // Whether to allow the viewing of all the photo thumbnails on a grid (defaults to YES)\nbrowser.startOnGrid = NO; // Whether to start on the grid of thumbnails instead of the first photo (defaults to NO)\nbrowser.autoPlayOnAppear = NO; // Auto-play first video\n\n// Customise selection images to change colours if required\nbrowser.customImageSelectedIconName = @\"ImageSelected.png\";\nbrowser.customImageSelectedSmallIconName = @\"ImageSelectedSmall.png\";\n\n// Optionally set the current visible photo before displaying\n[browser setCurrentPhotoIndex:1];\n\n// Present\n[self.navigationController pushViewController:browser animated:YES];\n\n// Manipulate\n[browser showNextPhotoAnimated:YES];\n[browser showPreviousPhotoAnimated:YES];\n[browser setCurrentPhotoIndex:10];\n```\n\nThen respond to the required delegate methods:\n\n```obj-c\n- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {\n    return self.photos.count;\n}\n\n- (id \u003cMWPhoto\u003e)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {\n    if (index \u003c self.photos.count) {\n        return [self.photos objectAtIndex:index];\n    }\n    return nil;\n}\n```\n\nYou 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.\n\n\n### Videos\n\nYou 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.\n\n```obj-c\n\n// Video with URL including poster photo\nMWPhoto *video = [MWPhoto photoWithURL:[NSURL URLWithString:@\"https://scontent.cdninstagram.com/hphotos-xpt1/t51.2885-15/e15/11192696_824079697688618_1761661_n.jpg\"]];\nvideo.videoURL = [NSURL URLWithString:@\"https://scontent.cdninstagram.com/hphotos-xpa1/t50.2886-16/11200303_1440130956287424_1714699187_n.mp4\"];\n\n// Video with PHAsset\nMWPhoto *video = [MWPhoto photoWithAsset:asset targetSize:[UIScreen mainScreen].bounds.size]; // Example sizing\n\n// Video with ALAsset\nMWPhoto *video = [MWPhoto photoWithURL:asset.defaultRepresentation.url];\nif ([asset valueForProperty:ALAssetPropertyType] == ALAssetTypeVideo) {\n    photo.videoURL = asset.defaultRepresentation.url;\n}\n\n// Video with no poster photo\nMWPhoto *video = [MWPhoto videoWithURL:[NSURL URLWithString:@\"https://scontent.cdninstagram.com/hphotos-xfa1/t50.2886-16/11237510_945154435524423_2137519922_n.mp4\"]];\n\n// Video grid thumbnail\nMWPhoto *videoThumb = [MWPhoto photoWithURL:[NSURL URLWithString:@\"https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s150x150/e15/11240463_963135443745570_1519872157_n.jpg\"]];\nvideoThumb.isVideo = YES;\n\n// Video grid thumbnail for video with no poster photo\nMWPhoto *videoThumb = [MWPhoto new];\nvideoThumb.isVideo = YES;\n\n```\n\n\n### Grid\n\nIn order to properly show the grid of thumbnails, you must ensure the property `enableGrid` is set to `YES`, and implement the following delegate method:\n\n```obj-c\n- (id \u003cMWPhoto\u003e)photoBrowser:(MWPhotoBrowser *)photoBrowser thumbPhotoAtIndex:(NSUInteger)index;\n```\n\nThe photo browser can also start on the grid by enabling the `startOnGrid` property.\n\n\n### Actions\n\nBy default, if the action button is visible then the image (and caption if it exists) are sent to a UIActivityViewController.\n\nYou can provide a custom action by implementing the following delegate method:\n\n```obj-c\n- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser actionButtonPressedForPhotoAtIndex:(NSUInteger)index {\n    // Do your thing!\n}\n```\n\n\n### Photo Captions\n\nPhoto captions can be displayed simply by setting the `caption` property on specific photos:\n\n```obj-c\nMWPhoto *photo = [MWPhoto photoWithURL:[NSURL URLWithString:@\"http://farm4.static.flickr.com/3629/3339128908_7aecabc34b.jpg\"]];\nphoto.caption = @\"Campervan\";\n```\n\nNo caption will be displayed if the caption property is not set.\n\n\n#### Custom Captions\n\nBy 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:\n\n1. Optionally use a subclass of `MWPhoto` for your photos so you can store more data than a simple caption string.\n2. 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`\n3. Implement the `-photoBrowser:captionViewForPhotoAtIndex:` MWPhotoBrowser delegate method (shown below).\n\nExample delegate method for custom caption view:\n\n```obj-c\n- (MWCaptionView *)photoBrowser:(MWPhotoBrowser *)photoBrowser captionViewForPhotoAtIndex:(NSUInteger)index {\n    MWPhoto *photo = [self.photos objectAtIndex:index];\n    MyMWCaptionViewSubclass *captionView = [[MyMWCaptionViewSubclass alloc] initWithPhoto:photo];\n    return captionView;\n}\n```\n\n\n#### Selections\n\nThe 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:\n\n```obj-c\n- (BOOL)photoBrowser:(MWPhotoBrowser *)photoBrowser isPhotoSelectedAtIndex:(NSUInteger)index {\n    return [[_selections objectAtIndex:index] boolValue];\n}\n\n- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index selectedChanged:(BOOL)selected {\n    [_selections replaceObjectAtIndex:index withObject:[NSNumber numberWithBool:selected]];\n}\n```\n\n\n## Installation\n\nMWPhotoBrowser is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"MWPhotoBrowser\"\n```\n\n\n## Usage\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\nThen 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):\n\n```obj-c\n#import \"MWPhotoBrowser.h\"\n```\n\nIf you are using Swift and frameworks, then you can just import the browser into your Swift source file:\n\n```swift\nimport MWPhotoBrowser\n```\n\n\n## Author\n\nMichael Waterfall, michael@d3i.com\n\n\n## License\n\nMWPhotoBrowser is available under the MIT license. See the LICENSE file for more info.\n\n\n## Notes\n\nDemo photos kindly provided by [Oliver Waters](\u003chttp://twitter.com/oliverwaters\u003e).\n","funding_links":[],"categories":["Media","Gallery","awesome-ios ##","Objective-C","UI","Objective-C  Stars 1000以内排名整理","Object-C 库","etc","Minor"],"sub_categories":["Image","Other free courses","Photo Browser"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmwaterfall%2FMWPhotoBrowser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmwaterfall%2FMWPhotoBrowser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmwaterfall%2FMWPhotoBrowser/lists"}