|
1 | 1 | MHFacebookImageViewer |
2 | 2 | ======================= |
3 | 3 |
|
4 | | -A new Image Viewer inspired by Facebook |
5 | | - |
6 | | - |
7 | | -## Screenshots |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
| 4 | +An Image Viewer inspired by Facebook |
14 | 5 |
|
| 6 | + |
15 | 7 |
|
16 | 8 | # Demo Video |
17 | 9 |
|
18 | 10 | http://youtu.be/NTs2COXxrrA |
19 | 11 |
|
20 | 12 |
|
| 13 | +# Supports |
21 | 14 |
|
22 | | -# Requirements |
23 | | - |
24 | | - |
25 | | -* Current version can run from iOS 5 to iOS 7 (But must be build < XCode 4.6.x) |
26 | | -* Please uncheck the Use AutoLayout in the property inspector of The UIStoryboard for IOS 5 Support  |
27 | | -* [AFNetworking](https://github.com/AFNetworking/AFNetworking) - for image lazy loading |
28 | | - |
29 | | - |
30 | | -# Usage |
| 15 | +- From iOS 10 |
| 16 | +- Swift versions |
| 17 | + - Swift 4.0 |
| 18 | + - Swift 4.2 |
| 19 | + - Swift 5.0 |
31 | 20 |
|
32 | 21 | ## How to use it |
33 | | -Just |
34 | | - |
35 | | - #import "MHFacebookImageViewer.h" |
36 | | - |
37 | | - |
38 | | -and then in your UIImageView after you set the Image just call the |
39 | | - |
40 | | -### Single Image Support |
41 | | - |
42 | | - - (void) setupImageViewer; |
43 | | - |
44 | | - - (void) setupImageViewerWithCompletionOnOpen:(MHFacebookImageViewerOpeningBlock)open onClose:(MHFacebookImageViewerClosingBlock)close; |
45 | | - |
46 | | - |
47 | | -or if you want to load other image (for example a hi-res version of that image) |
48 | | - |
49 | | - - (void) setupImageViewerWithImageURL:(NSURL*)url; |
50 | | - |
51 | | - - (void) setupImageViewerWithImageURL:(NSURL *)url onOpen:(MHFacebookImageViewerOpeningBlock)open onClose:(MHFacebookImageViewerClosingBlock)close; |
52 | | - |
53 | | -### Multiple Images Support |
54 | | - |
55 | | - - (void) setupImageViewerWithDatasource:(id<MHFacebookImageViewerDatasource>)imageDatasource onOpen:(MHFacebookImageViewerOpeningBlock)open onClose:(MHFacebookImageViewerClosingBlock)close; |
56 | | - |
57 | | - - (void) setupImageViewerWithDatasource:(id<MHFacebookImageViewerDatasource>)imageDatasource initialIndex:(NSInteger)initialIndex onOpen:(MHFacebookImageViewerOpeningBlock)open onClose:(MHFacebookImageViewerClosingBlock)close; |
58 | | - |
59 | | - |
60 | | -## Example (UITableViewController): |
61 | 22 |
|
62 | | -### In your UITableViewController import the MHFacebookImageViewer.h |
| 23 | +The simplest way to implement is with using `UIImageView().setupImageViewer(with: self)` |
63 | 24 |
|
64 | | - #import "MHFacebookImageViewer.h" |
65 | | - |
66 | | -### In your [UITableView cellForRowAtIndexPath] |
| 25 | +```swift |
| 26 | +imageView.setupImageViewer(with: self) |
| 27 | +``` |
67 | 28 |
|
68 | | - - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath |
69 | | - { |
70 | | - static NSString *CellIdentifier = @"image_cell"; |
71 | | - UITableViewCell *cell = UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
72 | | - UIImageView * imageView = (UIImageView*)[cell viewWithTag:1]; |
73 | | - |
74 | | - [imageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%i.png",indexPath.row]]]; |
75 | | - imageView.contentMode = UIViewContentModeScaleAspectFill; |
76 | | - [imageView setupImageViewer]; |
77 | | - imageView.clipsToBounds = YES; |
78 | | - return cell; |
79 | | - } |
| 29 | +```swift |
| 30 | +import MHFacebookImageViewer |
80 | 31 |
|
81 | | -### If you want to include multiple images, Here is the DataSource Protocol or look for the sample project included in this repo. |
82 | | - |
83 | | - - (NSInteger) numberImagesForImageViewer:(MHFacebookImageViewer*) imageViewer; |
84 | | - - (NSURL*) imageURLAtIndex:(NSInteger)index imageViewer:(MHFacebookImageViewer*) imageViewer; |
85 | | - - (UIImage*) imageDefaultAtIndex:(NSInteger)index imageViewer:(MHFacebookImageViewer*) imageViewer; |
| 32 | +let imageView = UIImageView() |
| 33 | +imageView.image = UIImage(named: 'cat1') |
| 34 | +... |
| 35 | +imageView.setupImageViewer(with: self) |
| 36 | +``` |
86 | 37 |
|
87 | | -### That's it. :) |
88 | 38 |
|
| 39 | +### And That's it. :) |
89 | 40 |
|
90 | | -Please let me know if you have any questions. |
| 41 | +Please let me know if you have any questions. |
91 | 42 |
|
92 | | -Cheers, |
| 43 | +Cheers, |
93 | 44 | [Michael Henry Pantaleon](http://www.iamkel.net) |
94 | 45 |
|
95 | 46 | Twitter: [@michaelhenry119](https://twitter.com/michaelhenry119) |
|
0 commit comments