├── .gitignore ├── MJPhotoBrowserDemo ├── MJPhotoBrowserDemo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── MJPhotoBrowserDemo.xcworkspace │ └── contents.xcworkspacedata ├── MJPhotoBrowserDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── Default-568h@2x.png │ ├── Default.png │ ├── Default@2x.png │ ├── Info.plist │ ├── MJPhotoBrowser │ │ ├── MBProgressHUD+Add.h │ │ ├── MBProgressHUD+Add.m │ │ ├── MJPhoto.h │ │ ├── MJPhoto.m │ │ ├── MJPhotoBrowser.bundle │ │ │ ├── save_icon.png │ │ │ ├── save_icon@2x.png │ │ │ ├── save_icon_highlighted.png │ │ │ └── save_icon_highlighted@2x.png │ │ ├── MJPhotoBrowser.h │ │ ├── MJPhotoBrowser.m │ │ ├── MJPhotoLoadingView.h │ │ ├── MJPhotoLoadingView.m │ │ ├── MJPhotoProgressView.h │ │ ├── MJPhotoProgressView.m │ │ ├── MJPhotoToolbar.h │ │ ├── MJPhotoToolbar.m │ │ ├── MJPhotoView.h │ │ ├── MJPhotoView.m │ │ ├── SDWebImageManager+MJ.h │ │ ├── SDWebImageManager+MJ.m │ │ ├── UIImageView+MJWebCache.h │ │ └── UIImageView+MJWebCache.m │ ├── ViewController.h │ ├── ViewController.m │ ├── main.m │ ├── timeline_image_loading.png │ └── timeline_image_loading@2x.png ├── MJPhotoBrowserDemoTests │ ├── Info.plist │ └── MJPhotoBrowserDemoTests.m ├── MJPhotoBrowserDemoUITests │ ├── Info.plist │ └── MJPhotoBrowserDemoUITests.m ├── Podfile ├── Podfile.lock └── Pods │ ├── Headers │ ├── Private │ │ ├── MBProgressHUD │ │ │ └── MBProgressHUD.h │ │ └── SDWebImage │ │ │ ├── NSData+ImageContentType.h │ │ │ ├── SDImageCache.h │ │ │ ├── SDWebImageCompat.h │ │ │ ├── SDWebImageDecoder.h │ │ │ ├── SDWebImageDownloader.h │ │ │ ├── SDWebImageDownloaderOperation.h │ │ │ ├── SDWebImageManager.h │ │ │ ├── SDWebImageOperation.h │ │ │ ├── SDWebImagePrefetcher.h │ │ │ ├── UIButton+WebCache.h │ │ │ ├── UIImage+GIF.h │ │ │ ├── UIImage+MultiFormat.h │ │ │ ├── UIImageView+HighlightedWebCache.h │ │ │ ├── UIImageView+WebCache.h │ │ │ └── UIView+WebCacheOperation.h │ └── Public │ │ ├── MBProgressHUD │ │ └── MBProgressHUD.h │ │ └── SDWebImage │ │ ├── NSData+ImageContentType.h │ │ ├── SDImageCache.h │ │ ├── SDWebImageCompat.h │ │ ├── SDWebImageDecoder.h │ │ ├── SDWebImageDownloader.h │ │ ├── SDWebImageDownloaderOperation.h │ │ ├── SDWebImageManager.h │ │ ├── SDWebImageOperation.h │ │ ├── SDWebImagePrefetcher.h │ │ ├── UIButton+WebCache.h │ │ ├── UIImage+GIF.h │ │ ├── UIImage+MultiFormat.h │ │ ├── UIImageView+HighlightedWebCache.h │ │ ├── UIImageView+WebCache.h │ │ └── UIView+WebCacheOperation.h │ ├── MBProgressHUD │ ├── LICENSE │ ├── MBProgressHUD.h │ ├── MBProgressHUD.m │ └── README.mdown │ ├── Manifest.lock │ ├── Pods.xcodeproj │ └── project.pbxproj │ ├── SDWebImage │ ├── LICENSE │ ├── README.md │ └── SDWebImage │ │ ├── NSData+ImageContentType.h │ │ ├── NSData+ImageContentType.m │ │ ├── SDImageCache.h │ │ ├── SDImageCache.m │ │ ├── SDWebImageCompat.h │ │ ├── SDWebImageCompat.m │ │ ├── SDWebImageDecoder.h │ │ ├── SDWebImageDecoder.m │ │ ├── SDWebImageDownloader.h │ │ ├── SDWebImageDownloader.m │ │ ├── SDWebImageDownloaderOperation.h │ │ ├── SDWebImageDownloaderOperation.m │ │ ├── SDWebImageManager.h │ │ ├── SDWebImageManager.m │ │ ├── SDWebImageOperation.h │ │ ├── SDWebImagePrefetcher.h │ │ ├── SDWebImagePrefetcher.m │ │ ├── UIButton+WebCache.h │ │ ├── UIButton+WebCache.m │ │ ├── UIImage+GIF.h │ │ ├── UIImage+GIF.m │ │ ├── UIImage+MultiFormat.h │ │ ├── UIImage+MultiFormat.m │ │ ├── UIImageView+HighlightedWebCache.h │ │ ├── UIImageView+HighlightedWebCache.m │ │ ├── UIImageView+WebCache.h │ │ ├── UIImageView+WebCache.m │ │ ├── UIView+WebCacheOperation.h │ │ └── UIView+WebCacheOperation.m │ └── Target Support Files │ ├── MBProgressHUD │ ├── MBProgressHUD-dummy.m │ ├── MBProgressHUD-prefix.pch │ └── MBProgressHUD.xcconfig │ ├── Pods-MJPhotoBrowserDemo │ ├── Pods-MJPhotoBrowserDemo-acknowledgements.markdown │ ├── Pods-MJPhotoBrowserDemo-acknowledgements.plist │ ├── Pods-MJPhotoBrowserDemo-dummy.m │ ├── Pods-MJPhotoBrowserDemo-frameworks.sh │ ├── Pods-MJPhotoBrowserDemo-resources.sh │ ├── Pods-MJPhotoBrowserDemo.debug.xcconfig │ └── Pods-MJPhotoBrowserDemo.release.xcconfig │ └── SDWebImage │ ├── SDWebImage-dummy.m │ ├── SDWebImage-prefix.pch │ └── SDWebImage.xcconfig ├── README.md └── screenshots ├── Simulator0.png └── Simulator3.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MJPhotoBrowserDemo 4 | // 5 | // Created by zuweizhong on 2017/1/11. 6 | // Copyright © 2017年 zuweizhong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // MJPhotoBrowserDemo 4 | // 5 | // Created by zuweizhong on 2017/1/11. 6 | // Copyright © 2017年 zuweizhong. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds]; 21 | self.window.backgroundColor = [UIColor whiteColor]; 22 | ViewController *vc = [[ViewController alloc]init]; 23 | UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc]; 24 | vc.navigationItem.title = @"MJPhotoBrowser图片浏览器"; 25 | self.window.rootViewController = nav; 26 | [self.window makeKeyAndVisible]; 27 | return YES; 28 | } 29 | 30 | 31 | - (void)applicationWillResignActive:(UIApplication *)application { 32 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 33 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 34 | } 35 | 36 | 37 | - (void)applicationDidEnterBackground:(UIApplication *)application { 38 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 39 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 40 | } 41 | 42 | 43 | - (void)applicationWillEnterForeground:(UIApplication *)application { 44 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 45 | } 46 | 47 | 48 | - (void)applicationDidBecomeActive:(UIApplication *)application { 49 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 50 | } 51 | 52 | 53 | - (void)applicationWillTerminate:(UIApplication *)application { 54 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 55 | } 56 | 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder-zwz/MJPhotoBrowser/4f9153b59c6047b7358643f82047f812a7c01af9/MJPhotoBrowserDemo/MJPhotoBrowserDemo/Default-568h@2x.png -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder-zwz/MJPhotoBrowser/4f9153b59c6047b7358643f82047f812a7c01af9/MJPhotoBrowserDemo/MJPhotoBrowserDemo/Default.png -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder-zwz/MJPhotoBrowser/4f9153b59c6047b7358643f82047f812a7c01af9/MJPhotoBrowserDemo/MJPhotoBrowserDemo/Default@2x.png -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | 33 | NSAppleMusicUsageDescription 34 | App需要您的同意,才能访问媒体资料库 35 | NSBluetoothPeripheralUsageDescription 36 | App需要您的同意,才能访问蓝牙 37 | NSCalendarsUsageDescription 38 | App需要您的同意,才能访问日历 39 | NSCameraUsageDescription 40 | App需要您的同意,才能访问相机 41 | NSHealthShareUsageDescription 42 | App需要您的同意,才能访问健康分享 43 | NSHealthUpdateUsageDescription 44 | App需要您的同意,才能访问健康更新 45 | NSMicrophoneUsageDescription 46 | App需要您的同意,才能访问麦克风 47 | NSMotionUsageDescription 48 | App需要您的同意,才能访问运动与健身 49 | NSPhotoLibraryUsageDescription 50 | App需要您的同意,才能访问相册 51 | NSRemindersUsageDescription 52 | App需要您的同意,才能访问提醒事项 53 | 54 | NSAppTransportSecurity 55 | 56 | NSAllowsArbitraryLoads 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MBProgressHUD+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // MBProgressHUD+Add.h 3 | // 视频客户端 4 | // 5 | // Created by mj on 13-4-18. 6 | // Copyright (c) 2013年 itcast. All rights reserved. 7 | // 8 | 9 | #import "MBProgressHUD.h" 10 | 11 | @interface MBProgressHUD (Add) 12 | 13 | + (void)showError:(NSString *)error toView:(UIView *)view; 14 | 15 | + (void)showSuccess:(NSString *)success toView:(UIView *)view; 16 | 17 | + (MBProgressHUD *)showMessage:(NSString *)message toView:(UIView *)view; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MBProgressHUD+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // MBProgressHUD+Add.m 3 | // 视频客户端 4 | // 5 | // Created by mj on 13-4-18. 6 | // Copyright (c) 2013年 itcast. All rights reserved. 7 | // 8 | 9 | #import "MBProgressHUD+Add.h" 10 | 11 | @implementation MBProgressHUD (Add) 12 | 13 | #pragma mark 显示信息 14 | + (void)show:(NSString *)text icon:(NSString *)icon view:(UIView *)view 15 | { 16 | if (view == nil) view = [UIApplication sharedApplication].keyWindow; 17 | // 快速显示一个提示信息 18 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES]; 19 | hud.bezelView.color = [UIColor blackColor]; 20 | hud.bezelView.style = MBProgressHUDBackgroundStyleBlur; 21 | // 设置图片 22 | hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"MBProgressHUD.bundle/%@", icon]]]; 23 | // 再设置模式 24 | hud.mode = MBProgressHUDModeCustomView; 25 | hud.label.text = text; 26 | hud.label.textColor = [UIColor whiteColor]; 27 | // 隐藏时候从父控件中移除 28 | hud.removeFromSuperViewOnHide = YES; 29 | // 1秒之后再消失 30 | [hud hideAnimated:YES afterDelay:1.0]; 31 | } 32 | 33 | #pragma mark 显示错误信息 34 | 35 | + (void)showError:(NSString *)error toView:(UIView *)view{ 36 | [self show:error icon:@"error.png" view:view]; 37 | } 38 | 39 | + (void)showSuccess:(NSString *)success toView:(UIView *)view 40 | { 41 | [self show:success icon:@"success.png" view:view]; 42 | } 43 | 44 | #pragma mark 显示一些信息 45 | 46 | + (MBProgressHUD *)showMessage:(NSString *)message toView:(UIView *)view 47 | { 48 | if (view == nil) view = [UIApplication sharedApplication].keyWindow; 49 | // 快速显示一个提示信息 50 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES]; 51 | hud.bezelView.color = [UIColor blackColor]; 52 | hud.bezelView.style = MBProgressHUDBackgroundStyleBlur; 53 | // 隐藏时候从父控件中移除 54 | hud.removeFromSuperViewOnHide = YES; 55 | hud.label.text = message; 56 | hud.label.textColor = [UIColor whiteColor]; 57 | // YES代表需要蒙版效果 58 | hud.dimBackground = NO; 59 | return hud; 60 | } 61 | @end 62 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhoto.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJPhoto.h 3 | // 4 | // Created by mj on 13-3-4. 5 | // Copyright (c) 2013年 itcast. All rights reserved. 6 | 7 | #import 8 | #import 9 | @interface MJPhoto : NSObject 10 | @property (nonatomic, strong) NSURL *url; 11 | @property (nonatomic, strong) UIImage *image; // 完整的图片 12 | @property (nonatomic, strong) NSString *photoDescription; // 描述 13 | 14 | @property (nonatomic, strong) UIImageView *srcImageView; // 来源view 15 | @property (nonatomic, strong, readonly) UIImage *placeholder; 16 | @property (nonatomic, strong, readonly) UIImage *capture; 17 | 18 | @property (nonatomic, assign) BOOL firstShow; 19 | 20 | // 是否已经保存到相册 21 | @property (nonatomic, assign) BOOL save; 22 | @property (nonatomic, assign) int index; // 索引 23 | @end 24 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhoto.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJPhoto.m 3 | // 4 | // Created by mj on 13-3-4. 5 | // Copyright (c) 2013年 itcast. All rights reserved. 6 | 7 | #import 8 | #import "MJPhoto.h" 9 | 10 | @implementation MJPhoto 11 | 12 | #pragma mark 截图 13 | - (UIImage *)capture:(UIView *)view 14 | { 15 | UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0.0); 16 | [view.layer renderInContext:UIGraphicsGetCurrentContext()]; 17 | UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); 18 | UIGraphicsEndImageContext(); 19 | return img; 20 | } 21 | 22 | - (void)setSrcImageView:(UIImageView *)srcImageView 23 | { 24 | _srcImageView = srcImageView; 25 | _placeholder = srcImageView.image; 26 | if (srcImageView.clipsToBounds) { 27 | _capture = [self capture:srcImageView]; 28 | } 29 | } 30 | 31 | @end -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoBrowser.bundle/save_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder-zwz/MJPhotoBrowser/4f9153b59c6047b7358643f82047f812a7c01af9/MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoBrowser.bundle/save_icon.png -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoBrowser.bundle/save_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder-zwz/MJPhotoBrowser/4f9153b59c6047b7358643f82047f812a7c01af9/MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoBrowser.bundle/save_icon@2x.png -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoBrowser.bundle/save_icon_highlighted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder-zwz/MJPhotoBrowser/4f9153b59c6047b7358643f82047f812a7c01af9/MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoBrowser.bundle/save_icon_highlighted.png -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoBrowser.bundle/save_icon_highlighted@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder-zwz/MJPhotoBrowser/4f9153b59c6047b7358643f82047f812a7c01af9/MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoBrowser.bundle/save_icon_highlighted@2x.png -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoBrowser.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJPhotoBrowser.h 3 | // 4 | // Created by mj on 13-3-4. 5 | // Copyright (c) 2013年 itcast. All rights reserved. 6 | 7 | #import 8 | #import "MJPhoto.h" 9 | #import "SDWebImageManager+MJ.h" 10 | #import "UIImageView+MJWebCache.h" 11 | @protocol MJPhotoBrowserDelegate; 12 | @interface MJPhotoBrowser : UIViewController 13 | // 代理 14 | @property (nonatomic, weak) id delegate; 15 | // 所有的图片对象 16 | @property (nonatomic, strong) NSArray *photos; 17 | // 当前展示的图片索引 18 | @property (nonatomic, assign) NSUInteger currentPhotoIndex; 19 | 20 | // 显示 21 | - (void)show; 22 | @end 23 | 24 | @protocol MJPhotoBrowserDelegate 25 | @optional 26 | // 切换到某一页图片 27 | - (void)photoBrowser:(MJPhotoBrowser *)photoBrowser didChangedToPageAtIndex:(NSUInteger)index; 28 | @end 29 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoBrowser.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJPhotoBrowser.m 3 | // 4 | // Created by mj on 13-3-4. 5 | // Copyright (c) 2013年 itcast. All rights reserved. 6 | 7 | #import 8 | #import "MJPhotoBrowser.h" 9 | #import "MJPhotoView.h" 10 | #import "MJPhotoToolbar.h" 11 | 12 | #define kPadding 10 13 | #define kPhotoViewTagOffset 1000 14 | #define kPhotoViewIndex(photoView) ([photoView tag] - kPhotoViewTagOffset) 15 | 16 | @interface MJPhotoBrowser () 17 | { 18 | // 滚动的view 19 | UIScrollView *_photoScrollView; 20 | // 所有的图片view 21 | NSMutableSet *_visiblePhotoViews; 22 | NSMutableSet *_reusablePhotoViews; 23 | // 工具条 24 | MJPhotoToolbar *_toolbar; 25 | 26 | // 一开始的状态栏 27 | BOOL _statusBarHiddenInited; 28 | } 29 | @end 30 | 31 | @implementation MJPhotoBrowser 32 | 33 | #pragma mark - Lifecycle 34 | - (void)loadView 35 | { 36 | _statusBarHiddenInited = [UIApplication sharedApplication].isStatusBarHidden; 37 | // 隐藏状态栏 38 | [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade]; 39 | self.view = [[UIView alloc] init]; 40 | self.view.frame = [UIScreen mainScreen].bounds; 41 | self.view.backgroundColor = [UIColor blackColor]; 42 | } 43 | 44 | - (void)viewDidLoad 45 | { 46 | [super viewDidLoad]; 47 | 48 | // 1.创建UIScrollView 49 | [self createScrollView]; 50 | 51 | // 2.创建工具条 52 | [self createToolbar]; 53 | } 54 | 55 | - (void)show 56 | { 57 | UIWindow *window = [UIApplication sharedApplication].keyWindow; 58 | [window addSubview:self.view]; 59 | [window.rootViewController addChildViewController:self]; 60 | 61 | if (_currentPhotoIndex == 0) { 62 | [self showPhotos]; 63 | } 64 | } 65 | 66 | #pragma mark - 私有方法 67 | #pragma mark 创建工具条 68 | - (void)createToolbar 69 | { 70 | CGFloat barHeight = 94; 71 | CGFloat barY = self.view.frame.size.height - barHeight; 72 | _toolbar = [[MJPhotoToolbar alloc] init]; 73 | _toolbar.frame = CGRectMake(0, barY, self.view.frame.size.width, barHeight); 74 | _toolbar.autoresizingMask = UIViewAutoresizingFlexibleTopMargin; 75 | _toolbar.photos = _photos; 76 | [self.view addSubview:_toolbar]; 77 | 78 | [self updateTollbarState]; 79 | } 80 | 81 | #pragma mark 创建UIScrollView 82 | - (void)createScrollView 83 | { 84 | CGRect frame = self.view.bounds; 85 | frame.origin.x -= kPadding; 86 | frame.size.width += (2 * kPadding); 87 | _photoScrollView = [[UIScrollView alloc] initWithFrame:frame]; 88 | _photoScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 89 | _photoScrollView.pagingEnabled = YES; 90 | _photoScrollView.delegate = self; 91 | _photoScrollView.showsHorizontalScrollIndicator = NO; 92 | _photoScrollView.showsVerticalScrollIndicator = NO; 93 | _photoScrollView.backgroundColor = [UIColor clearColor]; 94 | _photoScrollView.contentSize = CGSizeMake(frame.size.width * _photos.count, 0); 95 | [self.view addSubview:_photoScrollView]; 96 | _photoScrollView.contentOffset = CGPointMake(_currentPhotoIndex * frame.size.width, 0); 97 | } 98 | 99 | - (void)setPhotos:(NSArray *)photos 100 | { 101 | _photos = photos; 102 | 103 | if (photos.count > 1) { 104 | _visiblePhotoViews = [NSMutableSet set]; 105 | _reusablePhotoViews = [NSMutableSet set]; 106 | } 107 | 108 | for (int i = 0; i<_photos.count; i++) { 109 | MJPhoto *photo = _photos[i]; 110 | photo.index = i; 111 | photo.firstShow = i == _currentPhotoIndex; 112 | } 113 | } 114 | 115 | #pragma mark 设置选中的图片 116 | - (void)setCurrentPhotoIndex:(NSUInteger)currentPhotoIndex 117 | { 118 | _currentPhotoIndex = currentPhotoIndex; 119 | 120 | for (int i = 0; i<_photos.count; i++) { 121 | MJPhoto *photo = _photos[i]; 122 | photo.firstShow = i == currentPhotoIndex; 123 | } 124 | 125 | if ([self isViewLoaded]) { 126 | _photoScrollView.contentOffset = CGPointMake(_currentPhotoIndex * _photoScrollView.frame.size.width, 0); 127 | 128 | // 显示所有的相片 129 | [self showPhotos]; 130 | } 131 | } 132 | 133 | #pragma mark - MJPhotoView代理 134 | - (void)photoViewSingleTap:(MJPhotoView *)photoView 135 | { 136 | [UIApplication sharedApplication].statusBarHidden = _statusBarHiddenInited; 137 | self.view.backgroundColor = [UIColor clearColor]; 138 | 139 | // 移除工具条 140 | [_toolbar removeFromSuperview]; 141 | } 142 | 143 | - (void)photoViewDidEndZoom:(MJPhotoView *)photoView 144 | { 145 | [self.view removeFromSuperview]; 146 | [self removeFromParentViewController]; 147 | } 148 | 149 | - (void)photoViewImageFinishLoad:(MJPhotoView *)photoView 150 | { 151 | _toolbar.currentPhotoIndex = _currentPhotoIndex; 152 | } 153 | 154 | #pragma mark 显示照片 155 | - (void)showPhotos 156 | { 157 | // 只有一张图片 158 | if (_photos.count == 1) { 159 | [self showPhotoViewAtIndex:0]; 160 | return; 161 | } 162 | 163 | CGRect visibleBounds = _photoScrollView.bounds; 164 | NSInteger firstIndex = (int)floorf((CGRectGetMinX(visibleBounds)+kPadding*2) / CGRectGetWidth(visibleBounds)); 165 | NSInteger lastIndex = (int)floorf((CGRectGetMaxX(visibleBounds)-kPadding*2-1) / CGRectGetWidth(visibleBounds)); 166 | if (firstIndex < 0) firstIndex = 0; 167 | if (firstIndex >= _photos.count) firstIndex = _photos.count - 1; 168 | if (lastIndex < 0) lastIndex = 0; 169 | if (lastIndex >= _photos.count) lastIndex = _photos.count - 1; 170 | 171 | // 回收不再显示的ImageView 172 | NSInteger photoViewIndex; 173 | for (MJPhotoView *photoView in _visiblePhotoViews) { 174 | photoViewIndex = kPhotoViewIndex(photoView); 175 | if (photoViewIndex < firstIndex || photoViewIndex > lastIndex) { 176 | [_reusablePhotoViews addObject:photoView]; 177 | [photoView removeFromSuperview]; 178 | } 179 | } 180 | 181 | [_visiblePhotoViews minusSet:_reusablePhotoViews]; 182 | while (_reusablePhotoViews.count > 2) { 183 | [_reusablePhotoViews removeObject:[_reusablePhotoViews anyObject]]; 184 | } 185 | 186 | for (NSUInteger index = firstIndex; index <= lastIndex; index++) { 187 | if (![self isShowingPhotoViewAtIndex:index]) { 188 | [self showPhotoViewAtIndex:index]; 189 | } 190 | } 191 | } 192 | 193 | #pragma mark 显示一个图片view 194 | - (void)showPhotoViewAtIndex:(NSUInteger)index 195 | { 196 | MJPhotoView *photoView = [self dequeueReusablePhotoView]; 197 | if (!photoView) { // 添加新的图片view 198 | photoView = [[MJPhotoView alloc] init]; 199 | photoView.photoViewDelegate = self; 200 | } 201 | 202 | // 调整当期页的frame 203 | CGRect bounds = _photoScrollView.bounds; 204 | CGRect photoViewFrame = bounds; 205 | photoViewFrame.size.width -= (2 * kPadding); 206 | photoViewFrame.origin.x = (bounds.size.width * index) + kPadding; 207 | photoView.tag = kPhotoViewTagOffset + index; 208 | 209 | MJPhoto *photo = _photos[index]; 210 | photoView.frame = photoViewFrame; 211 | photoView.photo = photo; 212 | 213 | [_visiblePhotoViews addObject:photoView]; 214 | [_photoScrollView addSubview:photoView]; 215 | 216 | [self loadImageNearIndex:index]; 217 | } 218 | 219 | #pragma mark 加载index附近的图片 220 | - (void)loadImageNearIndex:(NSUInteger)index 221 | { 222 | if (index > 0) { 223 | MJPhoto *photo = _photos[index - 1]; 224 | [SDWebImageManager downloadWithURL:photo.url]; 225 | } 226 | 227 | if (index < _photos.count - 1) { 228 | MJPhoto *photo = _photos[index + 1]; 229 | [SDWebImageManager downloadWithURL:photo.url]; 230 | } 231 | } 232 | 233 | #pragma mark index这页是否正在显示 234 | - (BOOL)isShowingPhotoViewAtIndex:(NSUInteger)index { 235 | for (MJPhotoView *photoView in _visiblePhotoViews) { 236 | if (kPhotoViewIndex(photoView) == index) { 237 | return YES; 238 | } 239 | } 240 | return NO; 241 | } 242 | 243 | #pragma mark 循环利用某个view 244 | - (MJPhotoView *)dequeueReusablePhotoView 245 | { 246 | MJPhotoView *photoView = [_reusablePhotoViews anyObject]; 247 | if (photoView) { 248 | [_reusablePhotoViews removeObject:photoView]; 249 | } 250 | return photoView; 251 | } 252 | 253 | #pragma mark 更新toolbar状态 254 | - (void)updateTollbarState 255 | { 256 | _currentPhotoIndex = _photoScrollView.contentOffset.x / _photoScrollView.frame.size.width; 257 | _toolbar.currentPhotoIndex = _currentPhotoIndex; 258 | } 259 | 260 | #pragma mark - UIScrollView Delegate 261 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView { 262 | [self showPhotos]; 263 | [self updateTollbarState]; 264 | } 265 | @end 266 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoLoadingView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJPhotoLoadingView.h 3 | // 4 | // Created by mj on 13-3-4. 5 | // Copyright (c) 2013年 itcast. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #define kMinProgress 0.0001 11 | 12 | @class MJPhotoBrowser; 13 | @class MJPhoto; 14 | 15 | @interface MJPhotoLoadingView : UIView 16 | @property (nonatomic) float progress; 17 | 18 | - (void)showLoading; 19 | - (void)showFailure; 20 | @end -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoLoadingView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJPhotoLoadingView.m 3 | // 4 | // Created by mj on 13-3-4. 5 | // Copyright (c) 2013年 itcast. All rights reserved. 6 | // 7 | 8 | #import "MJPhotoLoadingView.h" 9 | #import "MJPhotoBrowser.h" 10 | #import 11 | #import "MJPhotoProgressView.h" 12 | 13 | @interface MJPhotoLoadingView () 14 | { 15 | UILabel *_failureLabel; 16 | MJPhotoProgressView *_progressView; 17 | } 18 | 19 | @end 20 | 21 | @implementation MJPhotoLoadingView 22 | 23 | - (void)setFrame:(CGRect)frame 24 | { 25 | [super setFrame:[UIScreen mainScreen].bounds]; 26 | } 27 | 28 | - (void)showFailure 29 | { 30 | [_progressView removeFromSuperview]; 31 | 32 | if (_failureLabel == nil) { 33 | _failureLabel = [[UILabel alloc] init]; 34 | _failureLabel.bounds = CGRectMake(0, 0, self.bounds.size.width, 44); 35 | _failureLabel.textAlignment = NSTextAlignmentCenter; 36 | _failureLabel.center = self.center; 37 | _failureLabel.text = @"网络不给力,图片下载失败"; 38 | _failureLabel.font = [UIFont boldSystemFontOfSize:20]; 39 | _failureLabel.textColor = [UIColor whiteColor]; 40 | _failureLabel.backgroundColor = [UIColor clearColor]; 41 | _failureLabel.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; 42 | } 43 | [self addSubview:_failureLabel]; 44 | } 45 | 46 | - (void)showLoading 47 | { 48 | [_failureLabel removeFromSuperview]; 49 | 50 | if (_progressView == nil) { 51 | _progressView = [[MJPhotoProgressView alloc] init]; 52 | _progressView.bounds = CGRectMake( 0, 0, 60, 60); 53 | _progressView.center = self.center; 54 | } 55 | _progressView.progress = kMinProgress; 56 | [self addSubview:_progressView]; 57 | } 58 | 59 | #pragma mark - customlize method 60 | - (void)setProgress:(float)progress 61 | { 62 | _progress = progress; 63 | _progressView.progress = progress; 64 | if (progress >= 1.0) { 65 | [_progressView removeFromSuperview]; 66 | } 67 | } 68 | @end 69 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoProgressView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJPhotoProgressView.h 3 | // 4 | // Created by mj on 13-3-4. 5 | // Copyright (c) 2013年 itcast. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface MJPhotoProgressView : UIView 11 | 12 | @property(nonatomic, strong) UIColor *trackTintColor; 13 | @property(nonatomic, strong) UIColor *progressTintColor; 14 | @property (nonatomic) float progress; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoProgressView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJPhotoProgressView.m 3 | // 4 | // Created by mj on 13-3-4. 5 | // Copyright (c) 2013年 itcast. All rights reserved. 6 | // 7 | 8 | #import "MJPhotoProgressView.h" 9 | 10 | #define kDegreeToRadian(x) (M_PI/180.0 * (x)) 11 | 12 | @implementation MJPhotoProgressView 13 | 14 | - (id)initWithFrame:(CGRect)frame 15 | { 16 | if (self = [super initWithFrame:frame]) { 17 | self.backgroundColor = [UIColor clearColor]; 18 | } 19 | return self; 20 | } 21 | 22 | - (void)drawRect:(CGRect)rect 23 | { 24 | CGPoint centerPoint = CGPointMake(rect.size.height / 2, rect.size.width / 2); 25 | CGFloat radius = MIN(rect.size.height, rect.size.width) / 2; 26 | 27 | CGFloat pathWidth = radius * 0.3f; 28 | 29 | CGFloat radians = kDegreeToRadian((_progress*359.9)-90); 30 | CGFloat xOffset = radius*(1 + 0.85*cosf(radians)); 31 | CGFloat yOffset = radius*(1 + 0.85*sinf(radians)); 32 | CGPoint endPoint = CGPointMake(xOffset, yOffset); 33 | 34 | CGContextRef context = UIGraphicsGetCurrentContext(); 35 | 36 | [self.trackTintColor setFill]; 37 | CGMutablePathRef trackPath = CGPathCreateMutable(); 38 | CGPathMoveToPoint(trackPath, NULL, centerPoint.x, centerPoint.y); 39 | CGPathAddArc(trackPath, NULL, centerPoint.x, centerPoint.y, radius, kDegreeToRadian(270), kDegreeToRadian(-90), NO); 40 | CGPathCloseSubpath(trackPath); 41 | CGContextAddPath(context, trackPath); 42 | CGContextFillPath(context); 43 | CGPathRelease(trackPath); 44 | 45 | [self.progressTintColor setFill]; 46 | CGMutablePathRef progressPath = CGPathCreateMutable(); 47 | CGPathMoveToPoint(progressPath, NULL, centerPoint.x, centerPoint.y); 48 | CGPathAddArc(progressPath, NULL, centerPoint.x, centerPoint.y, radius, kDegreeToRadian(270), radians, NO); 49 | CGPathCloseSubpath(progressPath); 50 | CGContextAddPath(context, progressPath); 51 | CGContextFillPath(context); 52 | CGPathRelease(progressPath); 53 | 54 | CGContextAddEllipseInRect(context, CGRectMake(centerPoint.x - pathWidth/2, 0, pathWidth, pathWidth)); 55 | CGContextFillPath(context); 56 | 57 | CGContextAddEllipseInRect(context, CGRectMake(endPoint.x - pathWidth/2, endPoint.y - pathWidth/2, pathWidth, pathWidth)); 58 | CGContextFillPath(context); 59 | 60 | CGContextSetBlendMode(context, kCGBlendModeClear);; 61 | CGFloat innerRadius = radius * 0.7; 62 | CGPoint newCenterPoint = CGPointMake(centerPoint.x - innerRadius, centerPoint.y - innerRadius); 63 | CGContextAddEllipseInRect(context, CGRectMake(newCenterPoint.x, newCenterPoint.y, innerRadius*2, innerRadius*2)); 64 | CGContextFillPath(context); 65 | } 66 | 67 | #pragma mark - Property Methods 68 | 69 | - (UIColor *)trackTintColor 70 | { 71 | if (!_trackTintColor) 72 | { 73 | _trackTintColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.7f]; 74 | } 75 | return _trackTintColor; 76 | } 77 | 78 | - (UIColor *)progressTintColor 79 | { 80 | if (!_progressTintColor) 81 | { 82 | _progressTintColor = [UIColor whiteColor]; 83 | } 84 | return _progressTintColor; 85 | } 86 | 87 | - (void)setProgress:(float)progress 88 | { 89 | _progress = progress; 90 | [self setNeedsDisplay]; 91 | } 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoToolbar.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJPhotoToolbar.h 3 | // FingerNews 4 | // 5 | // Created by mj on 13-9-24. 6 | // Copyright (c) 2013年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MJPhotoToolbar : UIView 12 | // 所有的图片对象 13 | @property (nonatomic, strong) NSArray *photos; 14 | // 当前展示的图片索引 15 | @property (nonatomic, assign) NSUInteger currentPhotoIndex; 16 | @end 17 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoToolbar.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJPhotoToolbar.m 3 | // FingerNews 4 | // 5 | // Created by mj on 13-9-24. 6 | // Copyright (c) 2013年 itcast. All rights reserved. 7 | // 8 | 9 | #import "MJPhotoToolbar.h" 10 | #import "MJPhoto.h" 11 | #import "MBProgressHUD+Add.h" 12 | 13 | @interface MJPhotoToolbar() 14 | { 15 | // 显示页码 16 | UILabel *_indexLabel; 17 | UIButton *_saveImageBtn; 18 | UITextView *_textView; 19 | } 20 | @end 21 | 22 | @implementation MJPhotoToolbar 23 | 24 | - (id)initWithFrame:(CGRect)frame 25 | { 26 | self = [super initWithFrame:frame]; 27 | if (self) { 28 | // Initialization code 29 | } 30 | return self; 31 | } 32 | 33 | - (void)setPhotos:(NSArray *)photos 34 | { 35 | _photos = photos; 36 | 37 | if (_photos.count > 1) { 38 | _indexLabel = [[UILabel alloc] init]; 39 | _indexLabel.font = [UIFont boldSystemFontOfSize:20]; 40 | _indexLabel.frame = CGRectMake(0, 50, [UIScreen mainScreen].bounds.size.width, 44); 41 | _indexLabel.backgroundColor = [UIColor clearColor]; 42 | _indexLabel.textColor = [UIColor whiteColor]; 43 | _indexLabel.textAlignment = NSTextAlignmentCenter; 44 | _indexLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 45 | [self addSubview:_indexLabel]; 46 | } 47 | 48 | // 保存图片按钮 49 | CGFloat btnWidth = 44; 50 | _saveImageBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 51 | _saveImageBtn.frame = CGRectMake(20, 50, btnWidth, btnWidth); 52 | _saveImageBtn.autoresizingMask = UIViewAutoresizingFlexibleHeight; 53 | [_saveImageBtn setImage:[UIImage imageNamed:@"MJPhotoBrowser.bundle/save_icon.png"] forState:UIControlStateNormal]; 54 | [_saveImageBtn setImage:[UIImage imageNamed:@"MJPhotoBrowser.bundle/save_icon_highlighted.png"] forState:UIControlStateHighlighted]; 55 | [_saveImageBtn addTarget:self action:@selector(saveImage) forControlEvents:UIControlEventTouchUpInside]; 56 | [self addSubview:_saveImageBtn]; 57 | 58 | _textView = [[UITextView alloc] init]; 59 | [_textView setFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 50)]; 60 | _textView.backgroundColor = [UIColor clearColor]; 61 | _textView.editable = NO; 62 | _textView.textAlignment = NSTextAlignmentLeft; 63 | _textView.textColor = [UIColor whiteColor]; 64 | _textView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 65 | [self addSubview:_textView]; 66 | } 67 | 68 | - (void)saveImage 69 | { 70 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 71 | MJPhoto *photo = _photos[_currentPhotoIndex]; 72 | UIImageWriteToSavedPhotosAlbum(photo.image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); 73 | }); 74 | } 75 | 76 | - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo 77 | { 78 | if (error) { 79 | [MBProgressHUD showSuccess:@"保存失败" toView:nil]; 80 | } else { 81 | MJPhoto *photo = _photos[_currentPhotoIndex]; 82 | photo.save = YES; 83 | _saveImageBtn.enabled = NO; 84 | [MBProgressHUD showSuccess:@"成功保存到相册" toView:nil]; 85 | } 86 | } 87 | 88 | - (void)setCurrentPhotoIndex:(NSUInteger)currentPhotoIndex 89 | { 90 | _currentPhotoIndex = currentPhotoIndex; 91 | 92 | // 更新页码 93 | _indexLabel.text = [NSString stringWithFormat:@"%lu / %lu", _currentPhotoIndex + 1, (unsigned long)_photos.count]; 94 | 95 | MJPhoto *photo = _photos[_currentPhotoIndex]; 96 | [_textView setText:photo.photoDescription]; 97 | // 按钮 98 | _saveImageBtn.enabled = photo.image != nil && !photo.save; 99 | } 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJZoomingScrollView.h 3 | // 4 | // Created by mj on 13-3-4. 5 | // Copyright (c) 2013年 itcast. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @class MJPhotoBrowser, MJPhoto, MJPhotoView; 11 | 12 | @protocol MJPhotoViewDelegate 13 | - (void)photoViewImageFinishLoad:(MJPhotoView *)photoView; 14 | - (void)photoViewSingleTap:(MJPhotoView *)photoView; 15 | - (void)photoViewDidEndZoom:(MJPhotoView *)photoView; 16 | @end 17 | 18 | @interface MJPhotoView : UIScrollView 19 | // 图片 20 | @property (nonatomic, strong) MJPhoto *photo; 21 | // 代理 22 | @property (nonatomic, weak) id photoViewDelegate; 23 | @end -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/MJPhotoView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJZoomingScrollView.m 3 | // 4 | // Created by mj on 13-3-4. 5 | // Copyright (c) 2013年 itcast. All rights reserved. 6 | // 7 | 8 | #import "MJPhotoView.h" 9 | #import "MJPhoto.h" 10 | #import "MJPhotoLoadingView.h" 11 | #import "UIImageView+WebCache.h" 12 | #import 13 | #import "SDImageCache.h" 14 | 15 | #define WEAK_OBJ(obj) __weak typeof(obj) __weak_##obj__ = obj; 16 | #define STRONG_OBJ(obj) __strong typeof ( __weak_##obj__ ) obj = __weak_##obj__; 17 | 18 | @interface MJPhotoView () 19 | { 20 | BOOL _doubleTap; 21 | UIImageView *_imageView; 22 | MJPhotoLoadingView *_photoLoadingView; 23 | } 24 | @end 25 | 26 | @implementation MJPhotoView 27 | 28 | - (id)initWithFrame:(CGRect)frame 29 | { 30 | if ((self = [super initWithFrame:frame])) { 31 | self.clipsToBounds = YES; 32 | // 图片 33 | _imageView = [[UIImageView alloc] init]; 34 | _imageView.contentMode = UIViewContentModeScaleAspectFit; 35 | [self addSubview:_imageView]; 36 | 37 | // 进度条 38 | _photoLoadingView = [[MJPhotoLoadingView alloc] init]; 39 | 40 | // 属性 41 | self.backgroundColor = [UIColor clearColor]; 42 | self.delegate = self; 43 | self.showsHorizontalScrollIndicator = NO; 44 | self.showsVerticalScrollIndicator = NO; 45 | self.decelerationRate = UIScrollViewDecelerationRateFast; 46 | self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 47 | 48 | // 监听点击 49 | UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)]; 50 | singleTap.delaysTouchesBegan = YES; 51 | singleTap.numberOfTapsRequired = 1; 52 | [self addGestureRecognizer:singleTap]; 53 | 54 | UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)]; 55 | doubleTap.numberOfTapsRequired = 2; 56 | [self addGestureRecognizer:doubleTap]; 57 | 58 | [singleTap requireGestureRecognizerToFail:doubleTap]; 59 | 60 | } 61 | return self; 62 | } 63 | 64 | #pragma mark - photoSetter 65 | - (void)setPhoto:(MJPhoto *)photo { 66 | _photo = photo; 67 | 68 | [self showImage]; 69 | } 70 | 71 | #pragma mark 显示图片 72 | - (void)showImage 73 | { 74 | if (_photo.firstShow) { // 首次显示 75 | _imageView.image = _photo.placeholder; // 占位图片 76 | _photo.srcImageView.image = nil; 77 | 78 | // 不是gif,就马上开始下载 79 | if (![_photo.url.absoluteString hasSuffix:@"gif"]) { 80 | __weak MJPhotoView *photoView = self; 81 | __weak MJPhoto *photo = _photo; 82 | [_imageView sd_setImageWithURL:_photo.url placeholderImage:_photo.placeholder options:SDWebImageRetryFailed|SDWebImageLowPriority completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 83 | photo.image = image; 84 | 85 | // 调整frame参数 86 | [photoView adjustFrame]; 87 | }]; 88 | } 89 | } else { 90 | [self photoStartLoad]; 91 | } 92 | 93 | // 调整frame参数 94 | [self adjustFrame]; 95 | } 96 | 97 | #pragma mark 开始加载图片 98 | - (void)photoStartLoad 99 | { 100 | if (_photo.image) { 101 | self.scrollEnabled = YES; 102 | _imageView.image = _photo.image; 103 | } else { 104 | self.scrollEnabled = NO; 105 | // 直接显示进度条 106 | [_photoLoadingView showLoading]; 107 | [self addSubview:_photoLoadingView]; 108 | 109 | __weak MJPhotoView *photoView = self; 110 | __weak MJPhotoLoadingView *loading = _photoLoadingView; 111 | WEAK_OBJ(loading) 112 | [_imageView sd_setImageWithURL:_photo.url placeholderImage:_photo.srcImageView.image options:SDWebImageRetryFailed|SDWebImageLowPriority progress:^(NSInteger receivedSize , NSInteger expectedSize) { 113 | STRONG_OBJ(loading) 114 | if (receivedSize > kMinProgress) { 115 | loading.progress = (float)receivedSize/expectedSize; 116 | } 117 | } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType , NSURL *imageUrl) { 118 | 119 | [photoView photoDidFinishLoadWithImage:image]; 120 | }]; 121 | 122 | } 123 | } 124 | 125 | #pragma mark 加载完毕 126 | - (void)photoDidFinishLoadWithImage:(UIImage *)image 127 | { 128 | if (image) { 129 | self.scrollEnabled = YES; 130 | _photo.image = image; 131 | [_photoLoadingView removeFromSuperview]; 132 | 133 | if ([self.photoViewDelegate respondsToSelector:@selector(photoViewImageFinishLoad:)]) { 134 | [self.photoViewDelegate photoViewImageFinishLoad:self]; 135 | } 136 | } else { 137 | [self addSubview:_photoLoadingView]; 138 | [_photoLoadingView showFailure]; 139 | } 140 | 141 | // 设置缩放比例 142 | [self adjustFrame]; 143 | } 144 | #pragma mark 调整frame 145 | - (void)adjustFrame 146 | { 147 | if (_imageView.image == nil) return; 148 | 149 | // 基本尺寸参数 150 | CGSize boundsSize = self.bounds.size; 151 | CGFloat boundsWidth = boundsSize.width; 152 | CGFloat boundsHeight = boundsSize.height; 153 | 154 | CGSize imageSize = _imageView.image.size; 155 | CGFloat imageWidth = imageSize.width; 156 | CGFloat imageHeight = imageSize.height; 157 | 158 | // 设置伸缩比例 159 | CGFloat minScale = boundsWidth / imageWidth; 160 | if (minScale > 1) { 161 | minScale = 1.0; 162 | } 163 | CGFloat maxScale = 3.0; 164 | if ([UIScreen instancesRespondToSelector:@selector(scale)]) { 165 | maxScale = maxScale / [[UIScreen mainScreen] scale]; 166 | } 167 | self.maximumZoomScale = maxScale; 168 | self.minimumZoomScale = minScale; 169 | self.zoomScale = minScale; 170 | 171 | CGRect imageFrame = CGRectMake(0, 0, boundsWidth, imageHeight * boundsWidth / imageWidth); 172 | // 内容尺寸 173 | self.contentSize = CGSizeMake(0, imageFrame.size.height); 174 | 175 | // y值 176 | if (imageFrame.size.height < boundsHeight) { 177 | imageFrame.origin.y = floorf((boundsHeight - imageFrame.size.height) / 2.0); 178 | } else { 179 | imageFrame.origin.y = 0; 180 | } 181 | 182 | if (_photo.firstShow) { // 第一次显示的图片 183 | _photo.firstShow = NO; // 已经显示过了 184 | _imageView.frame = [_photo.srcImageView convertRect:_photo.srcImageView.bounds toView:nil]; 185 | 186 | [UIView animateWithDuration:0.45 187 | delay:0 188 | usingSpringWithDamping:0.65 189 | initialSpringVelocity:0 190 | options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseOut 191 | animations:^{ 192 | 193 | _imageView.frame = imageFrame; 194 | 195 | } completion:^(BOOL finished) { 196 | // 设置底部的小图片 197 | _photo.srcImageView.image = _photo.placeholder; 198 | [self photoStartLoad]; 199 | }]; 200 | 201 | } else { 202 | _imageView.frame = imageFrame; 203 | } 204 | } 205 | 206 | #pragma mark - UIScrollViewDelegate 207 | - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { 208 | return _imageView; 209 | } 210 | 211 | - (void)scrollViewDidZoom:(UIScrollView *)scrollView { 212 | CGRect imageViewFrame = _imageView.frame; 213 | CGRect screenBounds = [UIScreen mainScreen].bounds; 214 | if (imageViewFrame.size.height > screenBounds.size.height) { 215 | imageViewFrame.origin.y = 0.0f; 216 | } else { 217 | imageViewFrame.origin.y = (screenBounds.size.height - imageViewFrame.size.height) / 2.0; 218 | } 219 | _imageView.frame = imageViewFrame; 220 | } 221 | 222 | #pragma mark - 手势处理 223 | - (void)handleSingleTap:(UITapGestureRecognizer *)tap { 224 | _doubleTap = NO; 225 | [self performSelector:@selector(hide) withObject:nil afterDelay:0.2]; 226 | } 227 | - (void)hide 228 | { 229 | if (_doubleTap) return; 230 | 231 | // 移除进度条 232 | [_photoLoadingView removeFromSuperview]; 233 | self.contentOffset = CGPointZero; 234 | 235 | // 清空底部的小图 236 | _photo.srcImageView.image = nil; 237 | 238 | CGFloat duration = 0.15; 239 | if (_photo.srcImageView.clipsToBounds) { 240 | [self performSelector:@selector(reset) withObject:nil afterDelay:duration]; 241 | } 242 | 243 | [UIView animateWithDuration:duration + 0.1 animations:^{ 244 | _imageView.frame = [_photo.srcImageView convertRect:_photo.srcImageView.bounds toView:nil]; 245 | 246 | // gif图片仅显示第0张 247 | if (_imageView.image.images) { 248 | _imageView.image = _imageView.image.images[0]; 249 | } 250 | 251 | // 通知代理 252 | if ([self.photoViewDelegate respondsToSelector:@selector(photoViewSingleTap:)]) { 253 | [self.photoViewDelegate photoViewSingleTap:self]; 254 | } 255 | } completion:^(BOOL finished) { 256 | // 设置底部的小图片 257 | _photo.srcImageView.image = _photo.placeholder; 258 | 259 | // 通知代理 260 | if ([self.photoViewDelegate respondsToSelector:@selector(photoViewDidEndZoom:)]) { 261 | [self.photoViewDelegate photoViewDidEndZoom:self]; 262 | } 263 | }]; 264 | } 265 | 266 | - (void)reset 267 | { 268 | _imageView.image = _photo.capture; 269 | _imageView.contentMode = UIViewContentModeScaleToFill; 270 | } 271 | 272 | - (void)handleDoubleTap:(UITapGestureRecognizer *)tap { 273 | _doubleTap = YES; 274 | 275 | CGPoint touchPoint = [tap locationInView:self]; 276 | if (self.zoomScale == self.maximumZoomScale) { 277 | [self setZoomScale:self.minimumZoomScale animated:YES]; 278 | } else { 279 | [self zoomToRect:CGRectMake(touchPoint.x, touchPoint.y, 1, 1) animated:YES]; 280 | } 281 | } 282 | /** 根据手指位置计算zoomRect */ 283 | - (CGRect)zoomRectForScale:(CGFloat)scale withCenter:(CGPoint)touchPoint 284 | { 285 | CGRect zoomRect; 286 | 287 | zoomRect.size.height = _imageView.frame.size.height / scale;; 288 | zoomRect.size.width = _imageView.frame.size.width / scale;; 289 | 290 | touchPoint = [self convertPoint:touchPoint toView:_imageView]; 291 | 292 | zoomRect.origin.x = touchPoint.x - ((zoomRect.size.width / 2.0)); 293 | zoomRect.origin.y = touchPoint.y - ((zoomRect.size.height / 2.0)); 294 | 295 | return zoomRect; 296 | } 297 | 298 | - (void)dealloc 299 | { 300 | // 取消请求 301 | [_imageView sd_setImageWithURL:[NSURL URLWithString:@"file:///abc"]]; 302 | } 303 | @end 304 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/SDWebImageManager+MJ.h: -------------------------------------------------------------------------------- 1 | // 2 | // SDWebImageManager+MJ.h 3 | // FingerNews 4 | // 5 | // Created by mj on 13-9-23. 6 | // Copyright (c) 2013年 itcast. All rights reserved. 7 | // 8 | 9 | #import "SDWebImageManager.h" 10 | 11 | @interface SDWebImageManager (MJ) 12 | + (void)downloadWithURL:(NSURL *)url; 13 | @end 14 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/SDWebImageManager+MJ.m: -------------------------------------------------------------------------------- 1 | // 2 | // SDWebImageManager+MJ.m 3 | // FingerNews 4 | // 5 | // Created by mj on 13-9-23. 6 | // Copyright (c) 2013年 itcast. All rights reserved. 7 | // 8 | 9 | #import "SDWebImageManager+MJ.h" 10 | 11 | @implementation SDWebImageManager (MJ) 12 | + (void)downloadWithURL:(NSURL *)url 13 | { 14 | // cmp不能为空 15 | [[self sharedManager] downloadImageWithURL:url options:SDWebImageLowPriority|SDWebImageRetryFailed progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 16 | 17 | }]; 18 | } 19 | @end 20 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/UIImageView+MJWebCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+MJWebCache.h 3 | // 4 | // Created by ZK on 16/7/19. 5 | // Copyright © 2016年 ZK. All rights reserved. 6 | // 7 | 8 | #import "UIImageView+WebCache.h" 9 | 10 | @interface UIImageView (MJWebCache) 11 | 12 | - (void)setImageURL:(NSURL *)url placeholder:(UIImage *)placeholder; 13 | - (void)setImageURLStr:(NSString *)urlStr placeholder:(UIImage *)placeholder; 14 | 15 | @end -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/MJPhotoBrowser/UIImageView+MJWebCache.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+MJWebCache.m 3 | // 4 | // Created by ZK on 16/7/19. 5 | // Copyright © 2016年 ZK. All rights reserved. 6 | // 7 | 8 | #import "UIImageView+MJWebCache.h" 9 | 10 | @implementation UIImageView (MJWebCache) 11 | - (void)setImageURL:(NSURL *)url placeholder:(UIImage *)placeholder 12 | { 13 | [self sd_setImageWithURL:url placeholderImage:placeholder 14 | options:SDWebImageRetryFailed | SDWebImageLowPriority]; 15 | } 16 | 17 | - (void)setImageURLStr:(NSString *)urlStr placeholder:(UIImage *)placeholder 18 | { 19 | [self setImageURL:[NSURL URLWithString:urlStr] 20 | placeholder:placeholder]; 21 | } 22 | @end 23 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // MJPhotoBrowserDemo 4 | // 5 | // Created by zuweizhong on 2017/1/11. 6 | // Copyright © 2017年 zuweizhong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // MJPhotoBrowserDemo 4 | // 5 | // Created by zuweizhong on 2017/1/11. 6 | // Copyright © 2017年 zuweizhong. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "MJPhotoBrowser.h" 11 | @interface ViewController () 12 | { 13 | NSArray *_urls; 14 | } 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad 20 | { 21 | [super viewDidLoad]; 22 | self.view.backgroundColor = [UIColor groupTableViewBackgroundColor]; 23 | // 0.图片链接 24 | _urls = @[@"http://ww4.sinaimg.cn/thumbnail/7f8c1087gw1e9g06pc68ug20ag05y4qq.gif", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr0nly5j20pf0gygo6.jpg", @"http://ww4.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr1d0vyj20pf0gytcj.jpg", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr1xydcj20gy0o9q6s.jpg", @"http://ww2.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr2n1jjj20gy0o9tcc.jpg", @"http://ww2.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr39ht9j20gy0o6q74.jpg", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr3xvtlj20gy0obadv.jpg", @"http://ww4.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr4nndfj20gy0o9q6i.jpg", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr57tn9j20gy0obn0f.jpg"]; 25 | 26 | // 1.创建9个UIImageView 27 | UIImage *placeholder = [UIImage imageNamed:@"timeline_image_loading.png"]; 28 | CGFloat width = 80; 29 | CGFloat height = 80; 30 | CGFloat margin = 5; 31 | CGFloat startX = (self.view.frame.size.width - 3 * width - 2 * margin) * 0.5; 32 | CGFloat startY = 80; 33 | for (int i = 0; i<9; i++) { 34 | UIImageView *imageView = [[UIImageView alloc] init]; 35 | [self.view addSubview:imageView]; 36 | 37 | // 计算位置 38 | int row = i/3; 39 | int column = i%3; 40 | CGFloat x = startX + column * (width + margin); 41 | CGFloat y = startY + row * (height + margin); 42 | imageView.frame = CGRectMake(x, y, width, height); 43 | 44 | // 下载图片 45 | [imageView setImageURLStr:_urls[i] placeholder:placeholder]; 46 | 47 | // 事件监听 48 | imageView.tag = i; 49 | imageView.userInteractionEnabled = YES; 50 | [imageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImage:)]]; 51 | 52 | // 内容模式 53 | imageView.clipsToBounds = YES; 54 | imageView.contentMode = UIViewContentModeScaleAspectFill; 55 | } 56 | } 57 | 58 | - (void)tapImage:(UITapGestureRecognizer *)tap 59 | { 60 | NSInteger count = _urls.count; 61 | // 1.封装图片数据 62 | NSMutableArray *photos = [NSMutableArray arrayWithCapacity:count]; 63 | for (int i = 0; i 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/timeline_image_loading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder-zwz/MJPhotoBrowser/4f9153b59c6047b7358643f82047f812a7c01af9/MJPhotoBrowserDemo/MJPhotoBrowserDemo/timeline_image_loading.png -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemo/timeline_image_loading@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder-zwz/MJPhotoBrowser/4f9153b59c6047b7358643f82047f812a7c01af9/MJPhotoBrowserDemo/MJPhotoBrowserDemo/timeline_image_loading@2x.png -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemoTests/MJPhotoBrowserDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJPhotoBrowserDemoTests.m 3 | // MJPhotoBrowserDemoTests 4 | // 5 | // Created by zuweizhong on 2017/1/11. 6 | // Copyright © 2017年 zuweizhong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MJPhotoBrowserDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation MJPhotoBrowserDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/MJPhotoBrowserDemoUITests/MJPhotoBrowserDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJPhotoBrowserDemoUITests.m 3 | // MJPhotoBrowserDemoUITests 4 | // 5 | // Created by zuweizhong on 2017/1/11. 6 | // Copyright © 2017年 zuweizhong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MJPhotoBrowserDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation MJPhotoBrowserDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, ‘8.0’ 2 | 3 | target 'MJPhotoBrowserDemo' do 4 | 5 | pod 'SDWebImage', '~> 3.7.5' 6 | pod 'MBProgressHUD', '~> 1.0.0' 7 | 8 | end 9 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MBProgressHUD (1.0.0) 3 | - SDWebImage (3.7.6): 4 | - SDWebImage/Core (= 3.7.6) 5 | - SDWebImage/Core (3.7.6) 6 | 7 | DEPENDENCIES: 8 | - MBProgressHUD (~> 1.0.0) 9 | - SDWebImage (~> 3.7.5) 10 | 11 | SPEC CHECKSUMS: 12 | MBProgressHUD: 4890f671c94e8a0f3cf959aa731e9de2f036d71a 13 | SDWebImage: c325cf02c30337336b95beff20a13df489ec0ec9 14 | 15 | PODFILE CHECKSUM: 5525f411bb627f828c33707937c2f66aeac6d190 16 | 17 | COCOAPODS: 1.1.1 18 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/MBProgressHUD/MBProgressHUD.h: -------------------------------------------------------------------------------- 1 | ../../../MBProgressHUD/MBProgressHUD.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/SDWebImage/NSData+ImageContentType.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/NSData+ImageContentType.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/SDWebImage/SDImageCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDImageCache.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/SDWebImage/SDWebImageCompat.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageCompat.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/SDWebImage/SDWebImageDecoder.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageDecoder.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/SDWebImage/SDWebImageDownloader.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageDownloader.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/SDWebImage/SDWebImageDownloaderOperation.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/SDWebImage/SDWebImageManager.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageManager.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/SDWebImage/SDWebImageOperation.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageOperation.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/SDWebImage/SDWebImagePrefetcher.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImagePrefetcher.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/SDWebImage/UIButton+WebCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIButton+WebCache.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/SDWebImage/UIImage+GIF.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImage+GIF.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/SDWebImage/UIImage+MultiFormat.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImage+MultiFormat.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/SDWebImage/UIImageView+HighlightedWebCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/SDWebImage/UIImageView+WebCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImageView+WebCache.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Private/SDWebImage/UIView+WebCacheOperation.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIView+WebCacheOperation.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/MBProgressHUD/MBProgressHUD.h: -------------------------------------------------------------------------------- 1 | ../../../MBProgressHUD/MBProgressHUD.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/SDWebImage/NSData+ImageContentType.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/NSData+ImageContentType.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/SDWebImage/SDImageCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDImageCache.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/SDWebImage/SDWebImageCompat.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageCompat.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/SDWebImage/SDWebImageDecoder.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageDecoder.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/SDWebImage/SDWebImageDownloader.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageDownloader.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/SDWebImage/SDWebImageDownloaderOperation.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/SDWebImage/SDWebImageManager.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageManager.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/SDWebImage/SDWebImageOperation.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImageOperation.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/SDWebImage/SDWebImagePrefetcher.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/SDWebImagePrefetcher.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/SDWebImage/UIButton+WebCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIButton+WebCache.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/SDWebImage/UIImage+GIF.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImage+GIF.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/SDWebImage/UIImage+MultiFormat.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImage+MultiFormat.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/SDWebImage/UIImageView+HighlightedWebCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/SDWebImage/UIImageView+WebCache.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIImageView+WebCache.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Headers/Public/SDWebImage/UIView+WebCacheOperation.h: -------------------------------------------------------------------------------- 1 | ../../../SDWebImage/SDWebImage/UIView+WebCacheOperation.h -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/MBProgressHUD/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2009-2016 Matej Bukovinski 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/MBProgressHUD/README.mdown: -------------------------------------------------------------------------------- 1 | # MBProgressHUD 2 | 3 | [![Build Status](https://travis-ci.org/matej/MBProgressHUD.svg?branch=master)](https://travis-ci.org/matej/MBProgressHUD) [![codecov.io](https://codecov.io/github/matej/MBProgressHUD/coverage.svg?branch=master)](https://codecov.io/github/matej/MBProgressHUD?branch=master) 4 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) [![CocoaPods compatible](https://img.shields.io/cocoapods/v/MBProgressHUD.svg?style=flat)](https://cocoapods.org/pods/MBProgressHUD) [![License: MIT](https://img.shields.io/cocoapods/l/MBProgressHUD.svg?style=flat)](http://opensource.org/licenses/MIT) 5 | 6 | `MBProgressHUD` is an iOS drop-in class that displays a translucent HUD with an indicator and/or labels while work is being done in a background thread. The HUD is meant as a replacement for the undocumented, private `UIKit` `UIProgressHUD` with some additional features. 7 | 8 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/1-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/1.png) 9 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/2-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/2.png) 10 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/3-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/3.png) 11 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/4-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/4.png) 12 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/5-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/5.png) 13 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/6-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/6.png) 14 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/7-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/7.png) 15 | 16 | **NOTE:** The class has recently undegone a major rewrite. The old version is available in the [legacy](https://github.com/jdg/MBProgressHUD/tree/legacy) branch, should you need it. 17 | 18 | ## Requirements 19 | 20 | `MBProgressHUD` works on iOS 6+ and requires ARC to build. It depends on the following Apple frameworks, which should already be included with most Xcode templates: 21 | 22 | * Foundation.framework 23 | * UIKit.framework 24 | * CoreGraphics.framework 25 | 26 | You will need the latest developer tools in order to build `MBProgressHUD`. Old Xcode versions might work, but compatibility will not be explicitly maintained. 27 | 28 | ## Adding MBProgressHUD to your project 29 | 30 | ### CocoaPods 31 | 32 | [CocoaPods](http://cocoapods.org) is the recommended way to add MBProgressHUD to your project. 33 | 34 | 1. Add a pod entry for MBProgressHUD to your Podfile `pod 'MBProgressHUD', '~> 1.0.0'` 35 | 2. Install the pod(s) by running `pod install`. 36 | 3. Include MBProgressHUD wherever you need it with `#import "MBProgressHUD.h"`. 37 | 38 | ### Carthage 39 | 40 | 1. Add MBProgressHUD to your Cartfile. e.g., `github "jdg/MBProgressHUD" ~> 1.0.0` 41 | 2. Run `carthage update` 42 | 3. Follow the rest of the [standard Carthage installation instructions](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) to add MBProgressHUD to your project. 43 | 44 | ### Source files 45 | 46 | Alternatively you can directly add the `MBProgressHUD.h` and `MBProgressHUD.m` source files to your project. 47 | 48 | 1. Download the [latest code version](https://github.com/matej/MBProgressHUD/archive/master.zip) or add the repository as a git submodule to your git-tracked project. 49 | 2. Open your project in Xcode, then drag and drop `MBProgressHUD.h` and `MBProgressHUD.m` onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project. 50 | 3. Include MBProgressHUD wherever you need it with `#import "MBProgressHUD.h"`. 51 | 52 | ### Static library 53 | 54 | You can also add MBProgressHUD as a static library to your project or workspace. 55 | 56 | 1. Download the [latest code version](https://github.com/matej/MBProgressHUD/downloads) or add the repository as a git submodule to your git-tracked project. 57 | 2. Open your project in Xcode, then drag and drop `MBProgressHUD.xcodeproj` onto your project or workspace (use the "Product Navigator view"). 58 | 3. Select your target and go to the Build phases tab. In the Link Binary With Libraries section select the add button. On the sheet find and add `libMBProgressHUD.a`. You might also need to add `MBProgressHUD` to the Target Dependencies list. 59 | 4. Include MBProgressHUD wherever you need it with `#import `. 60 | 61 | ## Usage 62 | 63 | The main guideline you need to follow when dealing with MBProgressHUD while running long-running tasks is keeping the main thread work-free, so the UI can be updated promptly. The recommended way of using MBProgressHUD is therefore to set it up on the main thread and then spinning the task, that you want to perform, off onto a new thread. 64 | 65 | ```objective-c 66 | [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 67 | dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ 68 | // Do something... 69 | dispatch_async(dispatch_get_main_queue(), ^{ 70 | [MBProgressHUD hideHUDForView:self.view animated:YES]; 71 | }); 72 | }); 73 | ``` 74 | 75 | You can add the HUD on any view or window. It is however a good idea to avoid adding the HUD to certain `UIKit` views with complex view hierarchies - like `UITableView` or `UICollectionView`. Those can mutate their subviews in unexpected ways and thereby break HUD display. 76 | 77 | If you need to configure the HUD you can do this by using the MBProgressHUD reference that showHUDAddedTo:animated: returns. 78 | 79 | ```objective-c 80 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 81 | hud.mode = MBProgressHUDModeAnnularDeterminate; 82 | hud.labelText = @"Loading"; 83 | [self doSomethingInBackgroundWithProgressCallback:^(float progress) { 84 | hud.progress = progress; 85 | } completionCallback:^{ 86 | [hud hide:YES]; 87 | }]; 88 | ``` 89 | 90 | You can also use a `NSProgress` object and MBProgressHUD will update itself when there is progress reported through that object. 91 | 92 | ```objective-c 93 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 94 | hud.mode = MBProgressHUDModeAnnularDeterminate; 95 | hud.labelText = @"Loading"; 96 | NSProgress *progress = [self doSomethingInBackgroundCompletion:^{ 97 | [hud hide:YES]; 98 | }]; 99 | hud.progressObject = progress; 100 | ``` 101 | 102 | UI updates should always be done on the main thread. Some MBProgressHUD setters are however considered "thread safe" and can be called from background threads. Those also include `setMode:`, `setCustomView:`, `setLabelText:`, `setLabelFont:`, `setDetailsLabelText:`, `setDetailsLabelFont:` and `setProgress:`. 103 | 104 | If you need to run your long-running task in the main thread, you should perform it with a slight delay, so UIKit will have enough time to update the UI (i.e., draw the HUD) before you block the main thread with your task. 105 | 106 | ```objective-c 107 | [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 108 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC); 109 | dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 110 | // Do something... 111 | [MBProgressHUD hideHUDForView:self.view animated:YES]; 112 | }); 113 | ``` 114 | 115 | You should be aware that any HUD updates issued inside the above block won't be displayed until the block completes. 116 | 117 | For more examples, including how to use MBProgressHUD with asynchronous operations such as NSURLConnection, take a look at the bundled demo project. Extensive API documentation is provided in the header file (MBProgressHUD.h). 118 | 119 | 120 | ## License 121 | 122 | This code is distributed under the terms and conditions of the [MIT license](LICENSE). 123 | 124 | ## Change-log 125 | 126 | A brief summary of each MBProgressHUD release can be found in the [CHANGELOG](CHANGELOG.mdown). 127 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MBProgressHUD (1.0.0) 3 | - SDWebImage (3.7.6): 4 | - SDWebImage/Core (= 3.7.6) 5 | - SDWebImage/Core (3.7.6) 6 | 7 | DEPENDENCIES: 8 | - MBProgressHUD (~> 1.0.0) 9 | - SDWebImage (~> 3.7.5) 10 | 11 | SPEC CHECKSUMS: 12 | MBProgressHUD: 4890f671c94e8a0f3cf959aa731e9de2f036d71a 13 | SDWebImage: c325cf02c30337336b95beff20a13df489ec0ec9 14 | 15 | PODFILE CHECKSUM: 5525f411bb627f828c33707937c2f66aeac6d190 16 | 17 | COCOAPODS: 1.1.1 18 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Olivier Poitrey rs@dailymotion.com 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Fabrice Aneche on 06/01/14. 3 | // Copyright (c) 2014 Dailymotion. All rights reserved. 4 | // 5 | 6 | #import 7 | 8 | @interface NSData (ImageContentType) 9 | 10 | /** 11 | * Compute the content type for an image data 12 | * 13 | * @param data the input data 14 | * 15 | * @return the content type as string (i.e. image/jpeg, image/gif) 16 | */ 17 | + (NSString *)sd_contentTypeForImageData:(NSData *)data; 18 | 19 | @end 20 | 21 | 22 | @interface NSData (ImageContentTypeDeprecated) 23 | 24 | + (NSString *)contentTypeForImageData:(NSData *)data __deprecated_msg("Use `sd_contentTypeForImageData:`"); 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Fabrice Aneche on 06/01/14. 3 | // Copyright (c) 2014 Dailymotion. All rights reserved. 4 | // 5 | 6 | #import "NSData+ImageContentType.h" 7 | 8 | 9 | @implementation NSData (ImageContentType) 10 | 11 | + (NSString *)sd_contentTypeForImageData:(NSData *)data { 12 | uint8_t c; 13 | [data getBytes:&c length:1]; 14 | switch (c) { 15 | case 0xFF: 16 | return @"image/jpeg"; 17 | case 0x89: 18 | return @"image/png"; 19 | case 0x47: 20 | return @"image/gif"; 21 | case 0x49: 22 | case 0x4D: 23 | return @"image/tiff"; 24 | case 0x52: 25 | // R as RIFF for WEBP 26 | if ([data length] < 12) { 27 | return nil; 28 | } 29 | 30 | NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding]; 31 | if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) { 32 | return @"image/webp"; 33 | } 34 | 35 | return nil; 36 | } 37 | return nil; 38 | } 39 | 40 | @end 41 | 42 | 43 | @implementation NSData (ImageContentTypeDeprecated) 44 | 45 | + (NSString *)contentTypeForImageData:(NSData *)data { 46 | return [self sd_contentTypeForImageData:data]; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/SDImageCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | 12 | typedef NS_ENUM(NSInteger, SDImageCacheType) { 13 | /** 14 | * The image wasn't available the SDWebImage caches, but was downloaded from the web. 15 | */ 16 | SDImageCacheTypeNone, 17 | /** 18 | * The image was obtained from the disk cache. 19 | */ 20 | SDImageCacheTypeDisk, 21 | /** 22 | * The image was obtained from the memory cache. 23 | */ 24 | SDImageCacheTypeMemory 25 | }; 26 | 27 | typedef void(^SDWebImageQueryCompletedBlock)(UIImage *image, SDImageCacheType cacheType); 28 | 29 | typedef void(^SDWebImageCheckCacheCompletionBlock)(BOOL isInCache); 30 | 31 | typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger totalSize); 32 | 33 | /** 34 | * SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed 35 | * asynchronous so it doesn’t add unnecessary latency to the UI. 36 | */ 37 | @interface SDImageCache : NSObject 38 | 39 | /** 40 | * Decompressing images that are downloaded and cached can improve performance but can consume lot of memory. 41 | * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption. 42 | */ 43 | @property (assign, nonatomic) BOOL shouldDecompressImages; 44 | 45 | /** 46 | * disable iCloud backup [defaults to YES] 47 | */ 48 | @property (assign, nonatomic) BOOL shouldDisableiCloud; 49 | 50 | /** 51 | * use memory cache [defaults to YES] 52 | */ 53 | @property (assign, nonatomic) BOOL shouldCacheImagesInMemory; 54 | 55 | /** 56 | * The maximum "total cost" of the in-memory image cache. The cost function is the number of pixels held in memory. 57 | */ 58 | @property (assign, nonatomic) NSUInteger maxMemoryCost; 59 | 60 | /** 61 | * The maximum number of objects the cache should hold. 62 | */ 63 | @property (assign, nonatomic) NSUInteger maxMemoryCountLimit; 64 | 65 | /** 66 | * The maximum length of time to keep an image in the cache, in seconds 67 | */ 68 | @property (assign, nonatomic) NSInteger maxCacheAge; 69 | 70 | /** 71 | * The maximum size of the cache, in bytes. 72 | */ 73 | @property (assign, nonatomic) NSUInteger maxCacheSize; 74 | 75 | /** 76 | * Returns global shared cache instance 77 | * 78 | * @return SDImageCache global instance 79 | */ 80 | + (SDImageCache *)sharedImageCache; 81 | 82 | /** 83 | * Init a new cache store with a specific namespace 84 | * 85 | * @param ns The namespace to use for this cache store 86 | */ 87 | - (id)initWithNamespace:(NSString *)ns; 88 | 89 | /** 90 | * Init a new cache store with a specific namespace and directory 91 | * 92 | * @param ns The namespace to use for this cache store 93 | * @param directory Directory to cache disk images in 94 | */ 95 | - (id)initWithNamespace:(NSString *)ns diskCacheDirectory:(NSString *)directory; 96 | 97 | -(NSString *)makeDiskCachePath:(NSString*)fullNamespace; 98 | 99 | /** 100 | * Add a read-only cache path to search for images pre-cached by SDImageCache 101 | * Useful if you want to bundle pre-loaded images with your app 102 | * 103 | * @param path The path to use for this read-only cache path 104 | */ 105 | - (void)addReadOnlyCachePath:(NSString *)path; 106 | 107 | /** 108 | * Store an image into memory and disk cache at the given key. 109 | * 110 | * @param image The image to store 111 | * @param key The unique image cache key, usually it's image absolute URL 112 | */ 113 | - (void)storeImage:(UIImage *)image forKey:(NSString *)key; 114 | 115 | /** 116 | * Store an image into memory and optionally disk cache at the given key. 117 | * 118 | * @param image The image to store 119 | * @param key The unique image cache key, usually it's image absolute URL 120 | * @param toDisk Store the image to disk cache if YES 121 | */ 122 | - (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk; 123 | 124 | /** 125 | * Store an image into memory and optionally disk cache at the given key. 126 | * 127 | * @param image The image to store 128 | * @param recalculate BOOL indicates if imageData can be used or a new data should be constructed from the UIImage 129 | * @param imageData The image data as returned by the server, this representation will be used for disk storage 130 | * instead of converting the given image object into a storable/compressed image format in order 131 | * to save quality and CPU 132 | * @param key The unique image cache key, usually it's image absolute URL 133 | * @param toDisk Store the image to disk cache if YES 134 | */ 135 | - (void)storeImage:(UIImage *)image recalculateFromImage:(BOOL)recalculate imageData:(NSData *)imageData forKey:(NSString *)key toDisk:(BOOL)toDisk; 136 | 137 | /** 138 | * Store image NSData into disk cache at the given key. 139 | * 140 | * @param imageData The image data to store 141 | * @param key The unique image cache key, usually it's image absolute URL 142 | */ 143 | - (void)storeImageDataToDisk:(NSData *)imageData forKey:(NSString *)key; 144 | 145 | /** 146 | * Query the disk cache asynchronously. 147 | * 148 | * @param key The unique key used to store the wanted image 149 | */ 150 | - (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(SDWebImageQueryCompletedBlock)doneBlock; 151 | 152 | /** 153 | * Query the memory cache synchronously. 154 | * 155 | * @param key The unique key used to store the wanted image 156 | */ 157 | - (UIImage *)imageFromMemoryCacheForKey:(NSString *)key; 158 | 159 | /** 160 | * Query the disk cache synchronously after checking the memory cache. 161 | * 162 | * @param key The unique key used to store the wanted image 163 | */ 164 | - (UIImage *)imageFromDiskCacheForKey:(NSString *)key; 165 | 166 | /** 167 | * Remove the image from memory and disk cache synchronously 168 | * 169 | * @param key The unique image cache key 170 | */ 171 | - (void)removeImageForKey:(NSString *)key; 172 | 173 | 174 | /** 175 | * Remove the image from memory and disk cache asynchronously 176 | * 177 | * @param key The unique image cache key 178 | * @param completion An block that should be executed after the image has been removed (optional) 179 | */ 180 | - (void)removeImageForKey:(NSString *)key withCompletion:(SDWebImageNoParamsBlock)completion; 181 | 182 | /** 183 | * Remove the image from memory and optionally disk cache asynchronously 184 | * 185 | * @param key The unique image cache key 186 | * @param fromDisk Also remove cache entry from disk if YES 187 | */ 188 | - (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk; 189 | 190 | /** 191 | * Remove the image from memory and optionally disk cache asynchronously 192 | * 193 | * @param key The unique image cache key 194 | * @param fromDisk Also remove cache entry from disk if YES 195 | * @param completion An block that should be executed after the image has been removed (optional) 196 | */ 197 | - (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(SDWebImageNoParamsBlock)completion; 198 | 199 | /** 200 | * Clear all memory cached images 201 | */ 202 | - (void)clearMemory; 203 | 204 | /** 205 | * Clear all disk cached images. Non-blocking method - returns immediately. 206 | * @param completion An block that should be executed after cache expiration completes (optional) 207 | */ 208 | - (void)clearDiskOnCompletion:(SDWebImageNoParamsBlock)completion; 209 | 210 | /** 211 | * Clear all disk cached images 212 | * @see clearDiskOnCompletion: 213 | */ 214 | - (void)clearDisk; 215 | 216 | /** 217 | * Remove all expired cached image from disk. Non-blocking method - returns immediately. 218 | * @param completionBlock An block that should be executed after cache expiration completes (optional) 219 | */ 220 | - (void)cleanDiskWithCompletionBlock:(SDWebImageNoParamsBlock)completionBlock; 221 | 222 | /** 223 | * Remove all expired cached image from disk 224 | * @see cleanDiskWithCompletionBlock: 225 | */ 226 | - (void)cleanDisk; 227 | 228 | /** 229 | * Get the size used by the disk cache 230 | */ 231 | - (NSUInteger)getSize; 232 | 233 | /** 234 | * Get the number of images in the disk cache 235 | */ 236 | - (NSUInteger)getDiskCount; 237 | 238 | /** 239 | * Asynchronously calculate the disk cache's size. 240 | */ 241 | - (void)calculateSizeWithCompletionBlock:(SDWebImageCalculateSizeBlock)completionBlock; 242 | 243 | /** 244 | * Async check if image exists in disk cache already (does not load the image) 245 | * 246 | * @param key the key describing the url 247 | * @param completionBlock the block to be executed when the check is done. 248 | * @note the completion block will be always executed on the main queue 249 | */ 250 | - (void)diskImageExistsWithKey:(NSString *)key completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; 251 | 252 | /** 253 | * Check if image exists in disk cache already (does not load the image) 254 | * 255 | * @param key the key describing the url 256 | * 257 | * @return YES if an image exists for the given key 258 | */ 259 | - (BOOL)diskImageExistsWithKey:(NSString *)key; 260 | 261 | /** 262 | * Get the cache path for a certain key (needs the cache path root folder) 263 | * 264 | * @param key the key (can be obtained from url using cacheKeyForURL) 265 | * @param path the cache path root folder 266 | * 267 | * @return the cache path 268 | */ 269 | - (NSString *)cachePathForKey:(NSString *)key inPath:(NSString *)path; 270 | 271 | /** 272 | * Get the default cache path for a certain key 273 | * 274 | * @param key the key (can be obtained from url using cacheKeyForURL) 275 | * 276 | * @return the default cache path 277 | */ 278 | - (NSString *)defaultCachePathForKey:(NSString *)key; 279 | 280 | @end 281 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/SDWebImageCompat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Jamie Pinkham 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #import 11 | 12 | #ifdef __OBJC_GC__ 13 | #error SDWebImage does not support Objective-C Garbage Collection 14 | #endif 15 | 16 | #if __IPHONE_OS_VERSION_MIN_REQUIRED != 20000 && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 17 | #error SDWebImage doesn't support Deployment Target version < 5.0 18 | #endif 19 | 20 | #if !TARGET_OS_IPHONE 21 | #import 22 | #ifndef UIImage 23 | #define UIImage NSImage 24 | #endif 25 | #ifndef UIImageView 26 | #define UIImageView NSImageView 27 | #endif 28 | #else 29 | 30 | #import 31 | 32 | #endif 33 | 34 | #ifndef NS_ENUM 35 | #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type 36 | #endif 37 | 38 | #ifndef NS_OPTIONS 39 | #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type 40 | #endif 41 | 42 | #if OS_OBJECT_USE_OBJC 43 | #undef SDDispatchQueueRelease 44 | #undef SDDispatchQueueSetterSementics 45 | #define SDDispatchQueueRelease(q) 46 | #define SDDispatchQueueSetterSementics strong 47 | #else 48 | #undef SDDispatchQueueRelease 49 | #undef SDDispatchQueueSetterSementics 50 | #define SDDispatchQueueRelease(q) (dispatch_release(q)) 51 | #define SDDispatchQueueSetterSementics assign 52 | #endif 53 | 54 | extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image); 55 | 56 | typedef void(^SDWebImageNoParamsBlock)(); 57 | 58 | extern NSString *const SDWebImageErrorDomain; 59 | 60 | #define dispatch_main_sync_safe(block)\ 61 | if ([NSThread isMainThread]) {\ 62 | block();\ 63 | } else {\ 64 | dispatch_sync(dispatch_get_main_queue(), block);\ 65 | } 66 | 67 | #define dispatch_main_async_safe(block)\ 68 | if ([NSThread isMainThread]) {\ 69 | block();\ 70 | } else {\ 71 | dispatch_async(dispatch_get_main_queue(), block);\ 72 | } 73 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/SDWebImageCompat.m: -------------------------------------------------------------------------------- 1 | // 2 | // SDWebImageCompat.m 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 11/12/12. 6 | // Copyright (c) 2012 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | #if !__has_feature(objc_arc) 12 | #error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag 13 | #endif 14 | 15 | inline UIImage *SDScaledImageForKey(NSString *key, UIImage *image) { 16 | if (!image) { 17 | return nil; 18 | } 19 | 20 | if ([image.images count] > 0) { 21 | NSMutableArray *scaledImages = [NSMutableArray array]; 22 | 23 | for (UIImage *tempImage in image.images) { 24 | [scaledImages addObject:SDScaledImageForKey(key, tempImage)]; 25 | } 26 | 27 | return [UIImage animatedImageWithImages:scaledImages duration:image.duration]; 28 | } 29 | else { 30 | if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { 31 | CGFloat scale = 1; 32 | if (key.length >= 8) { 33 | NSRange range = [key rangeOfString:@"@2x."]; 34 | if (range.location != NSNotFound) { 35 | scale = 2.0; 36 | } 37 | 38 | range = [key rangeOfString:@"@3x."]; 39 | if (range.location != NSNotFound) { 40 | scale = 3.0; 41 | } 42 | } 43 | 44 | UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; 45 | image = scaledImage; 46 | } 47 | return image; 48 | } 49 | } 50 | 51 | NSString *const SDWebImageErrorDomain = @"SDWebImageErrorDomain"; 52 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * Created by james on 9/28/11. 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | #import 12 | #import "SDWebImageCompat.h" 13 | 14 | @interface UIImage (ForceDecode) 15 | 16 | + (UIImage *)decodedImageWithImage:(UIImage *)image; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * Created by james on 9/28/11. 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | #import "SDWebImageDecoder.h" 12 | 13 | @implementation UIImage (ForceDecode) 14 | 15 | + (UIImage *)decodedImageWithImage:(UIImage *)image { 16 | // while downloading huge amount of images 17 | // autorelease the bitmap context 18 | // and all vars to help system to free memory 19 | // when there are memory warning. 20 | // on iOS7, do not forget to call 21 | // [[SDImageCache sharedImageCache] clearMemory]; 22 | 23 | if (image == nil) { // Prevent "CGBitmapContextCreateImage: invalid context 0x0" error 24 | return nil; 25 | } 26 | 27 | @autoreleasepool{ 28 | // do not decode animated images 29 | if (image.images != nil) { 30 | return image; 31 | } 32 | 33 | CGImageRef imageRef = image.CGImage; 34 | 35 | CGImageAlphaInfo alpha = CGImageGetAlphaInfo(imageRef); 36 | BOOL anyAlpha = (alpha == kCGImageAlphaFirst || 37 | alpha == kCGImageAlphaLast || 38 | alpha == kCGImageAlphaPremultipliedFirst || 39 | alpha == kCGImageAlphaPremultipliedLast); 40 | if (anyAlpha) { 41 | return image; 42 | } 43 | 44 | // current 45 | CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(CGImageGetColorSpace(imageRef)); 46 | CGColorSpaceRef colorspaceRef = CGImageGetColorSpace(imageRef); 47 | 48 | BOOL unsupportedColorSpace = (imageColorSpaceModel == kCGColorSpaceModelUnknown || 49 | imageColorSpaceModel == kCGColorSpaceModelMonochrome || 50 | imageColorSpaceModel == kCGColorSpaceModelCMYK || 51 | imageColorSpaceModel == kCGColorSpaceModelIndexed); 52 | if (unsupportedColorSpace) { 53 | colorspaceRef = CGColorSpaceCreateDeviceRGB(); 54 | } 55 | 56 | size_t width = CGImageGetWidth(imageRef); 57 | size_t height = CGImageGetHeight(imageRef); 58 | NSUInteger bytesPerPixel = 4; 59 | NSUInteger bytesPerRow = bytesPerPixel * width; 60 | NSUInteger bitsPerComponent = 8; 61 | 62 | 63 | // kCGImageAlphaNone is not supported in CGBitmapContextCreate. 64 | // Since the original image here has no alpha info, use kCGImageAlphaNoneSkipLast 65 | // to create bitmap graphics contexts without alpha info. 66 | CGContextRef context = CGBitmapContextCreate(NULL, 67 | width, 68 | height, 69 | bitsPerComponent, 70 | bytesPerRow, 71 | colorspaceRef, 72 | kCGBitmapByteOrderDefault|kCGImageAlphaNoneSkipLast); 73 | 74 | // Draw the image into the context and retrieve the new bitmap image without alpha 75 | CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); 76 | CGImageRef imageRefWithoutAlpha = CGBitmapContextCreateImage(context); 77 | UIImage *imageWithoutAlpha = [UIImage imageWithCGImage:imageRefWithoutAlpha 78 | scale:image.scale 79 | orientation:image.imageOrientation]; 80 | 81 | if (unsupportedColorSpace) { 82 | CGColorSpaceRelease(colorspaceRef); 83 | } 84 | 85 | CGContextRelease(context); 86 | CGImageRelease(imageRefWithoutAlpha); 87 | 88 | return imageWithoutAlpha; 89 | } 90 | } 91 | 92 | @end 93 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | #import "SDWebImageOperation.h" 12 | 13 | typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) { 14 | SDWebImageDownloaderLowPriority = 1 << 0, 15 | SDWebImageDownloaderProgressiveDownload = 1 << 1, 16 | 17 | /** 18 | * By default, request prevent the use of NSURLCache. With this flag, NSURLCache 19 | * is used with default policies. 20 | */ 21 | SDWebImageDownloaderUseNSURLCache = 1 << 2, 22 | 23 | /** 24 | * Call completion block with nil image/imageData if the image was read from NSURLCache 25 | * (to be combined with `SDWebImageDownloaderUseNSURLCache`). 26 | */ 27 | 28 | SDWebImageDownloaderIgnoreCachedResponse = 1 << 3, 29 | /** 30 | * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for 31 | * extra time in background to let the request finish. If the background task expires the operation will be cancelled. 32 | */ 33 | 34 | SDWebImageDownloaderContinueInBackground = 1 << 4, 35 | 36 | /** 37 | * Handles cookies stored in NSHTTPCookieStore by setting 38 | * NSMutableURLRequest.HTTPShouldHandleCookies = YES; 39 | */ 40 | SDWebImageDownloaderHandleCookies = 1 << 5, 41 | 42 | /** 43 | * Enable to allow untrusted SSL certificates. 44 | * Useful for testing purposes. Use with caution in production. 45 | */ 46 | SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6, 47 | 48 | /** 49 | * Put the image in the high priority queue. 50 | */ 51 | SDWebImageDownloaderHighPriority = 1 << 7, 52 | }; 53 | 54 | typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) { 55 | /** 56 | * Default value. All download operations will execute in queue style (first-in-first-out). 57 | */ 58 | SDWebImageDownloaderFIFOExecutionOrder, 59 | 60 | /** 61 | * All download operations will execute in stack style (last-in-first-out). 62 | */ 63 | SDWebImageDownloaderLIFOExecutionOrder 64 | }; 65 | 66 | extern NSString *const SDWebImageDownloadStartNotification; 67 | extern NSString *const SDWebImageDownloadStopNotification; 68 | 69 | typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize); 70 | 71 | typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished); 72 | 73 | typedef NSDictionary *(^SDWebImageDownloaderHeadersFilterBlock)(NSURL *url, NSDictionary *headers); 74 | 75 | /** 76 | * Asynchronous downloader dedicated and optimized for image loading. 77 | */ 78 | @interface SDWebImageDownloader : NSObject 79 | 80 | /** 81 | * Decompressing images that are downloaded and cached can improve performance but can consume lot of memory. 82 | * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption. 83 | */ 84 | @property (assign, nonatomic) BOOL shouldDecompressImages; 85 | 86 | @property (assign, nonatomic) NSInteger maxConcurrentDownloads; 87 | 88 | /** 89 | * Shows the current amount of downloads that still need to be downloaded 90 | */ 91 | @property (readonly, nonatomic) NSUInteger currentDownloadCount; 92 | 93 | 94 | /** 95 | * The timeout value (in seconds) for the download operation. Default: 15.0. 96 | */ 97 | @property (assign, nonatomic) NSTimeInterval downloadTimeout; 98 | 99 | 100 | /** 101 | * Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`. 102 | */ 103 | @property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder; 104 | 105 | /** 106 | * Singleton method, returns the shared instance 107 | * 108 | * @return global shared instance of downloader class 109 | */ 110 | + (SDWebImageDownloader *)sharedDownloader; 111 | 112 | /** 113 | * Set the default URL credential to be set for request operations. 114 | */ 115 | @property (strong, nonatomic) NSURLCredential *urlCredential; 116 | 117 | /** 118 | * Set username 119 | */ 120 | @property (strong, nonatomic) NSString *username; 121 | 122 | /** 123 | * Set password 124 | */ 125 | @property (strong, nonatomic) NSString *password; 126 | 127 | /** 128 | * Set filter to pick headers for downloading image HTTP request. 129 | * 130 | * This block will be invoked for each downloading image request, returned 131 | * NSDictionary will be used as headers in corresponding HTTP request. 132 | */ 133 | @property (nonatomic, copy) SDWebImageDownloaderHeadersFilterBlock headersFilter; 134 | 135 | /** 136 | * Set a value for a HTTP header to be appended to each download HTTP request. 137 | * 138 | * @param value The value for the header field. Use `nil` value to remove the header. 139 | * @param field The name of the header field to set. 140 | */ 141 | - (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field; 142 | 143 | /** 144 | * Returns the value of the specified HTTP header field. 145 | * 146 | * @return The value associated with the header field field, or `nil` if there is no corresponding header field. 147 | */ 148 | - (NSString *)valueForHTTPHeaderField:(NSString *)field; 149 | 150 | /** 151 | * Sets a subclass of `SDWebImageDownloaderOperation` as the default 152 | * `NSOperation` to be used each time SDWebImage constructs a request 153 | * operation to download an image. 154 | * 155 | * @param operationClass The subclass of `SDWebImageDownloaderOperation` to set 156 | * as default. Passing `nil` will revert to `SDWebImageDownloaderOperation`. 157 | */ 158 | - (void)setOperationClass:(Class)operationClass; 159 | 160 | /** 161 | * Creates a SDWebImageDownloader async downloader instance with a given URL 162 | * 163 | * The delegate will be informed when the image is finish downloaded or an error has happen. 164 | * 165 | * @see SDWebImageDownloaderDelegate 166 | * 167 | * @param url The URL to the image to download 168 | * @param options The options to be used for this download 169 | * @param progressBlock A block called repeatedly while the image is downloading 170 | * @param completedBlock A block called once the download is completed. 171 | * If the download succeeded, the image parameter is set, in case of error, 172 | * error parameter is set with the error. The last parameter is always YES 173 | * if SDWebImageDownloaderProgressiveDownload isn't use. With the 174 | * SDWebImageDownloaderProgressiveDownload option, this block is called 175 | * repeatedly with the partial image object and the finished argument set to NO 176 | * before to be called a last time with the full image and finished argument 177 | * set to YES. In case of error, the finished argument is always YES. 178 | * 179 | * @return A cancellable SDWebImageOperation 180 | */ 181 | - (id )downloadImageWithURL:(NSURL *)url 182 | options:(SDWebImageDownloaderOptions)options 183 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 184 | completed:(SDWebImageDownloaderCompletedBlock)completedBlock; 185 | 186 | /** 187 | * Sets the download queue suspension state 188 | */ 189 | - (void)setSuspended:(BOOL)suspended; 190 | 191 | /** 192 | * Cancels all download operations in the queue 193 | */ 194 | - (void)cancelAllDownloads; 195 | 196 | @end 197 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageDownloader.h" 10 | #import "SDWebImageDownloaderOperation.h" 11 | #import 12 | 13 | static NSString *const kProgressCallbackKey = @"progress"; 14 | static NSString *const kCompletedCallbackKey = @"completed"; 15 | 16 | @interface SDWebImageDownloader () 17 | 18 | @property (strong, nonatomic) NSOperationQueue *downloadQueue; 19 | @property (weak, nonatomic) NSOperation *lastAddedOperation; 20 | @property (assign, nonatomic) Class operationClass; 21 | @property (strong, nonatomic) NSMutableDictionary *URLCallbacks; 22 | @property (strong, nonatomic) NSMutableDictionary *HTTPHeaders; 23 | // This queue is used to serialize the handling of the network responses of all the download operation in a single queue 24 | @property (SDDispatchQueueSetterSementics, nonatomic) dispatch_queue_t barrierQueue; 25 | 26 | @end 27 | 28 | @implementation SDWebImageDownloader 29 | 30 | + (void)initialize { 31 | // Bind SDNetworkActivityIndicator if available (download it here: http://github.com/rs/SDNetworkActivityIndicator ) 32 | // To use it, just add #import "SDNetworkActivityIndicator.h" in addition to the SDWebImage import 33 | if (NSClassFromString(@"SDNetworkActivityIndicator")) { 34 | 35 | #pragma clang diagnostic push 36 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 37 | id activityIndicator = [NSClassFromString(@"SDNetworkActivityIndicator") performSelector:NSSelectorFromString(@"sharedActivityIndicator")]; 38 | #pragma clang diagnostic pop 39 | 40 | // Remove observer in case it was previously added. 41 | [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStartNotification object:nil]; 42 | [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStopNotification object:nil]; 43 | 44 | [[NSNotificationCenter defaultCenter] addObserver:activityIndicator 45 | selector:NSSelectorFromString(@"startActivity") 46 | name:SDWebImageDownloadStartNotification object:nil]; 47 | [[NSNotificationCenter defaultCenter] addObserver:activityIndicator 48 | selector:NSSelectorFromString(@"stopActivity") 49 | name:SDWebImageDownloadStopNotification object:nil]; 50 | } 51 | } 52 | 53 | + (SDWebImageDownloader *)sharedDownloader { 54 | static dispatch_once_t once; 55 | static id instance; 56 | dispatch_once(&once, ^{ 57 | instance = [self new]; 58 | }); 59 | return instance; 60 | } 61 | 62 | - (id)init { 63 | if ((self = [super init])) { 64 | _operationClass = [SDWebImageDownloaderOperation class]; 65 | _shouldDecompressImages = YES; 66 | _executionOrder = SDWebImageDownloaderFIFOExecutionOrder; 67 | _downloadQueue = [NSOperationQueue new]; 68 | _downloadQueue.maxConcurrentOperationCount = 6; 69 | _URLCallbacks = [NSMutableDictionary new]; 70 | #ifdef SD_WEBP 71 | _HTTPHeaders = [@{@"Accept": @"image/webp,image/*;q=0.8"} mutableCopy]; 72 | #else 73 | _HTTPHeaders = [@{@"Accept": @"image/*;q=0.8"} mutableCopy]; 74 | #endif 75 | _barrierQueue = dispatch_queue_create("com.hackemist.SDWebImageDownloaderBarrierQueue", DISPATCH_QUEUE_CONCURRENT); 76 | _downloadTimeout = 15.0; 77 | } 78 | return self; 79 | } 80 | 81 | - (void)dealloc { 82 | [self.downloadQueue cancelAllOperations]; 83 | SDDispatchQueueRelease(_barrierQueue); 84 | } 85 | 86 | - (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field { 87 | if (value) { 88 | self.HTTPHeaders[field] = value; 89 | } 90 | else { 91 | [self.HTTPHeaders removeObjectForKey:field]; 92 | } 93 | } 94 | 95 | - (NSString *)valueForHTTPHeaderField:(NSString *)field { 96 | return self.HTTPHeaders[field]; 97 | } 98 | 99 | - (void)setMaxConcurrentDownloads:(NSInteger)maxConcurrentDownloads { 100 | _downloadQueue.maxConcurrentOperationCount = maxConcurrentDownloads; 101 | } 102 | 103 | - (NSUInteger)currentDownloadCount { 104 | return _downloadQueue.operationCount; 105 | } 106 | 107 | - (NSInteger)maxConcurrentDownloads { 108 | return _downloadQueue.maxConcurrentOperationCount; 109 | } 110 | 111 | - (void)setOperationClass:(Class)operationClass { 112 | _operationClass = operationClass ?: [SDWebImageDownloaderOperation class]; 113 | } 114 | 115 | - (id )downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageDownloaderCompletedBlock)completedBlock { 116 | __block SDWebImageDownloaderOperation *operation; 117 | __weak __typeof(self)wself = self; 118 | 119 | [self addProgressCallback:progressBlock completedBlock:completedBlock forURL:url createCallback:^{ 120 | NSTimeInterval timeoutInterval = wself.downloadTimeout; 121 | if (timeoutInterval == 0.0) { 122 | timeoutInterval = 15.0; 123 | } 124 | 125 | // In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests if told otherwise 126 | NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:(options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:timeoutInterval]; 127 | request.HTTPShouldHandleCookies = (options & SDWebImageDownloaderHandleCookies); 128 | request.HTTPShouldUsePipelining = YES; 129 | if (wself.headersFilter) { 130 | request.allHTTPHeaderFields = wself.headersFilter(url, [wself.HTTPHeaders copy]); 131 | } 132 | else { 133 | request.allHTTPHeaderFields = wself.HTTPHeaders; 134 | } 135 | operation = [[wself.operationClass alloc] initWithRequest:request 136 | options:options 137 | progress:^(NSInteger receivedSize, NSInteger expectedSize) { 138 | SDWebImageDownloader *sself = wself; 139 | if (!sself) return; 140 | __block NSArray *callbacksForURL; 141 | dispatch_sync(sself.barrierQueue, ^{ 142 | callbacksForURL = [sself.URLCallbacks[url] copy]; 143 | }); 144 | for (NSDictionary *callbacks in callbacksForURL) { 145 | dispatch_async(dispatch_get_main_queue(), ^{ 146 | SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey]; 147 | if (callback) callback(receivedSize, expectedSize); 148 | }); 149 | } 150 | } 151 | completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) { 152 | SDWebImageDownloader *sself = wself; 153 | if (!sself) return; 154 | __block NSArray *callbacksForURL; 155 | dispatch_barrier_sync(sself.barrierQueue, ^{ 156 | callbacksForURL = [sself.URLCallbacks[url] copy]; 157 | if (finished) { 158 | [sself.URLCallbacks removeObjectForKey:url]; 159 | } 160 | }); 161 | for (NSDictionary *callbacks in callbacksForURL) { 162 | SDWebImageDownloaderCompletedBlock callback = callbacks[kCompletedCallbackKey]; 163 | if (callback) callback(image, data, error, finished); 164 | } 165 | } 166 | cancelled:^{ 167 | SDWebImageDownloader *sself = wself; 168 | if (!sself) return; 169 | dispatch_barrier_async(sself.barrierQueue, ^{ 170 | [sself.URLCallbacks removeObjectForKey:url]; 171 | }); 172 | }]; 173 | operation.shouldDecompressImages = wself.shouldDecompressImages; 174 | 175 | if (wself.urlCredential) { 176 | operation.credential = wself.urlCredential; 177 | } else if (wself.username && wself.password) { 178 | operation.credential = [NSURLCredential credentialWithUser:wself.username password:wself.password persistence:NSURLCredentialPersistenceForSession]; 179 | } 180 | 181 | if (options & SDWebImageDownloaderHighPriority) { 182 | operation.queuePriority = NSOperationQueuePriorityHigh; 183 | } else if (options & SDWebImageDownloaderLowPriority) { 184 | operation.queuePriority = NSOperationQueuePriorityLow; 185 | } 186 | 187 | [wself.downloadQueue addOperation:operation]; 188 | if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) { 189 | // Emulate LIFO execution order by systematically adding new operations as last operation's dependency 190 | [wself.lastAddedOperation addDependency:operation]; 191 | wself.lastAddedOperation = operation; 192 | } 193 | }]; 194 | 195 | return operation; 196 | } 197 | 198 | - (void)addProgressCallback:(SDWebImageDownloaderProgressBlock)progressBlock completedBlock:(SDWebImageDownloaderCompletedBlock)completedBlock forURL:(NSURL *)url createCallback:(SDWebImageNoParamsBlock)createCallback { 199 | // The URL will be used as the key to the callbacks dictionary so it cannot be nil. If it is nil immediately call the completed block with no image or data. 200 | if (url == nil) { 201 | if (completedBlock != nil) { 202 | completedBlock(nil, nil, nil, NO); 203 | } 204 | return; 205 | } 206 | 207 | dispatch_barrier_sync(self.barrierQueue, ^{ 208 | BOOL first = NO; 209 | if (!self.URLCallbacks[url]) { 210 | self.URLCallbacks[url] = [NSMutableArray new]; 211 | first = YES; 212 | } 213 | 214 | // Handle single download of simultaneous download request for the same URL 215 | NSMutableArray *callbacksForURL = self.URLCallbacks[url]; 216 | NSMutableDictionary *callbacks = [NSMutableDictionary new]; 217 | if (progressBlock) callbacks[kProgressCallbackKey] = [progressBlock copy]; 218 | if (completedBlock) callbacks[kCompletedCallbackKey] = [completedBlock copy]; 219 | [callbacksForURL addObject:callbacks]; 220 | self.URLCallbacks[url] = callbacksForURL; 221 | 222 | if (first) { 223 | createCallback(); 224 | } 225 | }); 226 | } 227 | 228 | - (void)setSuspended:(BOOL)suspended { 229 | [self.downloadQueue setSuspended:suspended]; 230 | } 231 | 232 | - (void)cancelAllDownloads { 233 | [self.downloadQueue cancelAllOperations]; 234 | } 235 | 236 | @end 237 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageDownloader.h" 11 | #import "SDWebImageOperation.h" 12 | 13 | extern NSString *const SDWebImageDownloadStartNotification; 14 | extern NSString *const SDWebImageDownloadReceiveResponseNotification; 15 | extern NSString *const SDWebImageDownloadStopNotification; 16 | extern NSString *const SDWebImageDownloadFinishNotification; 17 | 18 | @interface SDWebImageDownloaderOperation : NSOperation 19 | 20 | /** 21 | * The request used by the operation's connection. 22 | */ 23 | @property (strong, nonatomic, readonly) NSURLRequest *request; 24 | 25 | 26 | @property (assign, nonatomic) BOOL shouldDecompressImages; 27 | 28 | /** 29 | * Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. 30 | * 31 | * This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. 32 | */ 33 | @property (nonatomic, assign) BOOL shouldUseCredentialStorage; 34 | 35 | /** 36 | * The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. 37 | * 38 | * This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. 39 | */ 40 | @property (nonatomic, strong) NSURLCredential *credential; 41 | 42 | /** 43 | * The SDWebImageDownloaderOptions for the receiver. 44 | */ 45 | @property (assign, nonatomic, readonly) SDWebImageDownloaderOptions options; 46 | 47 | /** 48 | * The expected size of data. 49 | */ 50 | @property (assign, nonatomic) NSInteger expectedSize; 51 | 52 | /** 53 | * The response returned by the operation's connection. 54 | */ 55 | @property (strong, nonatomic) NSURLResponse *response; 56 | 57 | /** 58 | * Initializes a `SDWebImageDownloaderOperation` object 59 | * 60 | * @see SDWebImageDownloaderOperation 61 | * 62 | * @param request the URL request 63 | * @param options downloader options 64 | * @param progressBlock the block executed when a new chunk of data arrives. 65 | * @note the progress block is executed on a background queue 66 | * @param completedBlock the block executed when the download is done. 67 | * @note the completed block is executed on the main queue for success. If errors are found, there is a chance the block will be executed on a background queue 68 | * @param cancelBlock the block executed if the download (operation) is cancelled 69 | * 70 | * @return the initialized instance 71 | */ 72 | - (id)initWithRequest:(NSURLRequest *)request 73 | options:(SDWebImageDownloaderOptions)options 74 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 75 | completed:(SDWebImageDownloaderCompletedBlock)completedBlock 76 | cancelled:(SDWebImageNoParamsBlock)cancelBlock; 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/SDWebImageManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | #import "SDWebImageOperation.h" 11 | #import "SDWebImageDownloader.h" 12 | #import "SDImageCache.h" 13 | 14 | typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) { 15 | /** 16 | * By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying. 17 | * This flag disable this blacklisting. 18 | */ 19 | SDWebImageRetryFailed = 1 << 0, 20 | 21 | /** 22 | * By default, image downloads are started during UI interactions, this flags disable this feature, 23 | * leading to delayed download on UIScrollView deceleration for instance. 24 | */ 25 | SDWebImageLowPriority = 1 << 1, 26 | 27 | /** 28 | * This flag disables on-disk caching 29 | */ 30 | SDWebImageCacheMemoryOnly = 1 << 2, 31 | 32 | /** 33 | * This flag enables progressive download, the image is displayed progressively during download as a browser would do. 34 | * By default, the image is only displayed once completely downloaded. 35 | */ 36 | SDWebImageProgressiveDownload = 1 << 3, 37 | 38 | /** 39 | * Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed. 40 | * The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation. 41 | * This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics. 42 | * If a cached image is refreshed, the completion block is called once with the cached image and again with the final image. 43 | * 44 | * Use this flag only if you can't make your URLs static with embedded cache busting parameter. 45 | */ 46 | SDWebImageRefreshCached = 1 << 4, 47 | 48 | /** 49 | * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for 50 | * extra time in background to let the request finish. If the background task expires the operation will be cancelled. 51 | */ 52 | SDWebImageContinueInBackground = 1 << 5, 53 | 54 | /** 55 | * Handles cookies stored in NSHTTPCookieStore by setting 56 | * NSMutableURLRequest.HTTPShouldHandleCookies = YES; 57 | */ 58 | SDWebImageHandleCookies = 1 << 6, 59 | 60 | /** 61 | * Enable to allow untrusted SSL certificates. 62 | * Useful for testing purposes. Use with caution in production. 63 | */ 64 | SDWebImageAllowInvalidSSLCertificates = 1 << 7, 65 | 66 | /** 67 | * By default, images are loaded in the order in which they were queued. This flag moves them to 68 | * the front of the queue. 69 | */ 70 | SDWebImageHighPriority = 1 << 8, 71 | 72 | /** 73 | * By default, placeholder images are loaded while the image is loading. This flag will delay the loading 74 | * of the placeholder image until after the image has finished loading. 75 | */ 76 | SDWebImageDelayPlaceholder = 1 << 9, 77 | 78 | /** 79 | * We usually don't call transformDownloadedImage delegate method on animated images, 80 | * as most transformation code would mangle it. 81 | * Use this flag to transform them anyway. 82 | */ 83 | SDWebImageTransformAnimatedImage = 1 << 10, 84 | 85 | /** 86 | * By default, image is added to the imageView after download. But in some cases, we want to 87 | * have the hand before setting the image (apply a filter or add it with cross-fade animation for instance) 88 | * Use this flag if you want to manually set the image in the completion when success 89 | */ 90 | SDWebImageAvoidAutoSetImage = 1 << 11 91 | }; 92 | 93 | typedef void(^SDWebImageCompletionBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL); 94 | 95 | typedef void(^SDWebImageCompletionWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL); 96 | 97 | typedef NSString *(^SDWebImageCacheKeyFilterBlock)(NSURL *url); 98 | 99 | 100 | @class SDWebImageManager; 101 | 102 | @protocol SDWebImageManagerDelegate 103 | 104 | @optional 105 | 106 | /** 107 | * Controls which image should be downloaded when the image is not found in the cache. 108 | * 109 | * @param imageManager The current `SDWebImageManager` 110 | * @param imageURL The url of the image to be downloaded 111 | * 112 | * @return Return NO to prevent the downloading of the image on cache misses. If not implemented, YES is implied. 113 | */ 114 | - (BOOL)imageManager:(SDWebImageManager *)imageManager shouldDownloadImageForURL:(NSURL *)imageURL; 115 | 116 | /** 117 | * Allows to transform the image immediately after it has been downloaded and just before to cache it on disk and memory. 118 | * NOTE: This method is called from a global queue in order to not to block the main thread. 119 | * 120 | * @param imageManager The current `SDWebImageManager` 121 | * @param image The image to transform 122 | * @param imageURL The url of the image to transform 123 | * 124 | * @return The transformed image object. 125 | */ 126 | - (UIImage *)imageManager:(SDWebImageManager *)imageManager transformDownloadedImage:(UIImage *)image withURL:(NSURL *)imageURL; 127 | 128 | @end 129 | 130 | /** 131 | * The SDWebImageManager is the class behind the UIImageView+WebCache category and likes. 132 | * It ties the asynchronous downloader (SDWebImageDownloader) with the image cache store (SDImageCache). 133 | * You can use this class directly to benefit from web image downloading with caching in another context than 134 | * a UIView. 135 | * 136 | * Here is a simple example of how to use SDWebImageManager: 137 | * 138 | * @code 139 | 140 | SDWebImageManager *manager = [SDWebImageManager sharedManager]; 141 | [manager downloadImageWithURL:imageURL 142 | options:0 143 | progress:nil 144 | completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 145 | if (image) { 146 | // do something with image 147 | } 148 | }]; 149 | 150 | * @endcode 151 | */ 152 | @interface SDWebImageManager : NSObject 153 | 154 | @property (weak, nonatomic) id delegate; 155 | 156 | @property (strong, nonatomic, readonly) SDImageCache *imageCache; 157 | @property (strong, nonatomic, readonly) SDWebImageDownloader *imageDownloader; 158 | 159 | /** 160 | * The cache filter is a block used each time SDWebImageManager need to convert an URL into a cache key. This can 161 | * be used to remove dynamic part of an image URL. 162 | * 163 | * The following example sets a filter in the application delegate that will remove any query-string from the 164 | * URL before to use it as a cache key: 165 | * 166 | * @code 167 | 168 | [[SDWebImageManager sharedManager] setCacheKeyFilter:^(NSURL *url) { 169 | url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path]; 170 | return [url absoluteString]; 171 | }]; 172 | 173 | * @endcode 174 | */ 175 | @property (nonatomic, copy) SDWebImageCacheKeyFilterBlock cacheKeyFilter; 176 | 177 | /** 178 | * Returns global SDWebImageManager instance. 179 | * 180 | * @return SDWebImageManager shared instance 181 | */ 182 | + (SDWebImageManager *)sharedManager; 183 | 184 | /** 185 | * Downloads the image at the given URL if not present in cache or return the cached version otherwise. 186 | * 187 | * @param url The URL to the image 188 | * @param options A mask to specify options to use for this request 189 | * @param progressBlock A block called while image is downloading 190 | * @param completedBlock A block called when operation has been completed. 191 | * 192 | * This parameter is required. 193 | * 194 | * This block has no return value and takes the requested UIImage as first parameter. 195 | * In case of error the image parameter is nil and the second parameter may contain an NSError. 196 | * 197 | * The third parameter is an `SDImageCacheType` enum indicating if the image was retrieved from the local cache 198 | * or from the memory cache or from the network. 199 | * 200 | * The last parameter is set to NO when the SDWebImageProgressiveDownload option is used and the image is 201 | * downloading. This block is thus called repeatedly with a partial image. When image is fully downloaded, the 202 | * block is called a last time with the full image and the last parameter set to YES. 203 | * 204 | * @return Returns an NSObject conforming to SDWebImageOperation. Should be an instance of SDWebImageDownloaderOperation 205 | */ 206 | - (id )downloadImageWithURL:(NSURL *)url 207 | options:(SDWebImageOptions)options 208 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 209 | completed:(SDWebImageCompletionWithFinishedBlock)completedBlock; 210 | 211 | /** 212 | * Saves image to cache for given URL 213 | * 214 | * @param image The image to cache 215 | * @param url The URL to the image 216 | * 217 | */ 218 | 219 | - (void)saveImageToCache:(UIImage *)image forURL:(NSURL *)url; 220 | 221 | /** 222 | * Cancel all current operations 223 | */ 224 | - (void)cancelAll; 225 | 226 | /** 227 | * Check one or more operations running 228 | */ 229 | - (BOOL)isRunning; 230 | 231 | /** 232 | * Check if image has already been cached 233 | * 234 | * @param url image url 235 | * 236 | * @return if the image was already cached 237 | */ 238 | - (BOOL)cachedImageExistsForURL:(NSURL *)url; 239 | 240 | /** 241 | * Check if image has already been cached on disk only 242 | * 243 | * @param url image url 244 | * 245 | * @return if the image was already cached (disk only) 246 | */ 247 | - (BOOL)diskImageExistsForURL:(NSURL *)url; 248 | 249 | /** 250 | * Async check if image has already been cached 251 | * 252 | * @param url image url 253 | * @param completionBlock the block to be executed when the check is finished 254 | * 255 | * @note the completion block is always executed on the main queue 256 | */ 257 | - (void)cachedImageExistsForURL:(NSURL *)url 258 | completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; 259 | 260 | /** 261 | * Async check if image has already been cached on disk only 262 | * 263 | * @param url image url 264 | * @param completionBlock the block to be executed when the check is finished 265 | * 266 | * @note the completion block is always executed on the main queue 267 | */ 268 | - (void)diskImageExistsForURL:(NSURL *)url 269 | completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; 270 | 271 | 272 | /** 273 | *Return the cache key for a given URL 274 | */ 275 | - (NSString *)cacheKeyForURL:(NSURL *)url; 276 | 277 | @end 278 | 279 | 280 | #pragma mark - Deprecated 281 | 282 | typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionBlock`"); 283 | typedef void(^SDWebImageCompletedWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionWithFinishedBlock`"); 284 | 285 | 286 | @interface SDWebImageManager (Deprecated) 287 | 288 | /** 289 | * Downloads the image at the given URL if not present in cache or return the cached version otherwise. 290 | * 291 | * @deprecated This method has been deprecated. Use `downloadImageWithURL:options:progress:completed:` 292 | */ 293 | - (id )downloadWithURL:(NSURL *)url 294 | options:(SDWebImageOptions)options 295 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 296 | completed:(SDWebImageCompletedWithFinishedBlock)completedBlock __deprecated_msg("Method deprecated. Use `downloadImageWithURL:options:progress:completed:`"); 297 | 298 | @end 299 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/SDWebImageOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | 11 | @protocol SDWebImageOperation 12 | 13 | - (void)cancel; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageManager.h" 11 | 12 | @class SDWebImagePrefetcher; 13 | 14 | @protocol SDWebImagePrefetcherDelegate 15 | 16 | @optional 17 | 18 | /** 19 | * Called when an image was prefetched. 20 | * 21 | * @param imagePrefetcher The current image prefetcher 22 | * @param imageURL The image url that was prefetched 23 | * @param finishedCount The total number of images that were prefetched (successful or not) 24 | * @param totalCount The total number of images that were to be prefetched 25 | */ 26 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(NSURL *)imageURL finishedCount:(NSUInteger)finishedCount totalCount:(NSUInteger)totalCount; 27 | 28 | /** 29 | * Called when all images are prefetched. 30 | * @param imagePrefetcher The current image prefetcher 31 | * @param totalCount The total number of images that were prefetched (whether successful or not) 32 | * @param skippedCount The total number of images that were skipped 33 | */ 34 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didFinishWithTotalCount:(NSUInteger)totalCount skippedCount:(NSUInteger)skippedCount; 35 | 36 | @end 37 | 38 | typedef void(^SDWebImagePrefetcherProgressBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfTotalUrls); 39 | typedef void(^SDWebImagePrefetcherCompletionBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfSkippedUrls); 40 | 41 | /** 42 | * Prefetch some URLs in the cache for future use. Images are downloaded in low priority. 43 | */ 44 | @interface SDWebImagePrefetcher : NSObject 45 | 46 | /** 47 | * The web image manager 48 | */ 49 | @property (strong, nonatomic, readonly) SDWebImageManager *manager; 50 | 51 | /** 52 | * Maximum number of URLs to prefetch at the same time. Defaults to 3. 53 | */ 54 | @property (nonatomic, assign) NSUInteger maxConcurrentDownloads; 55 | 56 | /** 57 | * SDWebImageOptions for prefetcher. Defaults to SDWebImageLowPriority. 58 | */ 59 | @property (nonatomic, assign) SDWebImageOptions options; 60 | 61 | /** 62 | * Queue options for Prefetcher. Defaults to Main Queue. 63 | */ 64 | @property (nonatomic, assign) dispatch_queue_t prefetcherQueue; 65 | 66 | @property (weak, nonatomic) id delegate; 67 | 68 | /** 69 | * Return the global image prefetcher instance. 70 | */ 71 | + (SDWebImagePrefetcher *)sharedImagePrefetcher; 72 | 73 | /** 74 | * Allows you to instantiate a prefetcher with any arbitrary image manager. 75 | */ 76 | - (id)initWithImageManager:(SDWebImageManager *)manager; 77 | 78 | /** 79 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, 80 | * currently one image is downloaded at a time, 81 | * and skips images for failed downloads and proceed to the next image in the list 82 | * 83 | * @param urls list of URLs to prefetch 84 | */ 85 | - (void)prefetchURLs:(NSArray *)urls; 86 | 87 | /** 88 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, 89 | * currently one image is downloaded at a time, 90 | * and skips images for failed downloads and proceed to the next image in the list 91 | * 92 | * @param urls list of URLs to prefetch 93 | * @param progressBlock block to be called when progress updates; 94 | * first parameter is the number of completed (successful or not) requests, 95 | * second parameter is the total number of images originally requested to be prefetched 96 | * @param completionBlock block to be called when prefetching is completed 97 | * first param is the number of completed (successful or not) requests, 98 | * second parameter is the number of skipped requests 99 | */ 100 | - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock; 101 | 102 | /** 103 | * Remove and cancel queued list 104 | */ 105 | - (void)cancelPrefetching; 106 | 107 | 108 | @end 109 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImagePrefetcher.h" 10 | 11 | @interface SDWebImagePrefetcher () 12 | 13 | @property (strong, nonatomic) SDWebImageManager *manager; 14 | @property (strong, nonatomic) NSArray *prefetchURLs; 15 | @property (assign, nonatomic) NSUInteger requestedCount; 16 | @property (assign, nonatomic) NSUInteger skippedCount; 17 | @property (assign, nonatomic) NSUInteger finishedCount; 18 | @property (assign, nonatomic) NSTimeInterval startedTime; 19 | @property (copy, nonatomic) SDWebImagePrefetcherCompletionBlock completionBlock; 20 | @property (copy, nonatomic) SDWebImagePrefetcherProgressBlock progressBlock; 21 | 22 | @end 23 | 24 | @implementation SDWebImagePrefetcher 25 | 26 | + (SDWebImagePrefetcher *)sharedImagePrefetcher { 27 | static dispatch_once_t once; 28 | static id instance; 29 | dispatch_once(&once, ^{ 30 | instance = [self new]; 31 | }); 32 | return instance; 33 | } 34 | 35 | - (id)init { 36 | return [self initWithImageManager:[SDWebImageManager new]]; 37 | } 38 | 39 | - (id)initWithImageManager:(SDWebImageManager *)manager { 40 | if ((self = [super init])) { 41 | _manager = manager; 42 | _options = SDWebImageLowPriority; 43 | _prefetcherQueue = dispatch_get_main_queue(); 44 | self.maxConcurrentDownloads = 3; 45 | } 46 | return self; 47 | } 48 | 49 | - (void)setMaxConcurrentDownloads:(NSUInteger)maxConcurrentDownloads { 50 | self.manager.imageDownloader.maxConcurrentDownloads = maxConcurrentDownloads; 51 | } 52 | 53 | - (NSUInteger)maxConcurrentDownloads { 54 | return self.manager.imageDownloader.maxConcurrentDownloads; 55 | } 56 | 57 | - (void)startPrefetchingAtIndex:(NSUInteger)index { 58 | if (index >= self.prefetchURLs.count) return; 59 | self.requestedCount++; 60 | [self.manager downloadImageWithURL:self.prefetchURLs[index] options:self.options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 61 | if (!finished) return; 62 | self.finishedCount++; 63 | 64 | if (image) { 65 | if (self.progressBlock) { 66 | self.progressBlock(self.finishedCount,[self.prefetchURLs count]); 67 | } 68 | } 69 | else { 70 | if (self.progressBlock) { 71 | self.progressBlock(self.finishedCount,[self.prefetchURLs count]); 72 | } 73 | // Add last failed 74 | self.skippedCount++; 75 | } 76 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didPrefetchURL:finishedCount:totalCount:)]) { 77 | [self.delegate imagePrefetcher:self 78 | didPrefetchURL:self.prefetchURLs[index] 79 | finishedCount:self.finishedCount 80 | totalCount:self.prefetchURLs.count 81 | ]; 82 | } 83 | if (self.prefetchURLs.count > self.requestedCount) { 84 | dispatch_async(self.prefetcherQueue, ^{ 85 | [self startPrefetchingAtIndex:self.requestedCount]; 86 | }); 87 | } else if (self.finishedCount == self.requestedCount) { 88 | [self reportStatus]; 89 | if (self.completionBlock) { 90 | self.completionBlock(self.finishedCount, self.skippedCount); 91 | self.completionBlock = nil; 92 | } 93 | self.progressBlock = nil; 94 | } 95 | }]; 96 | } 97 | 98 | - (void)reportStatus { 99 | NSUInteger total = [self.prefetchURLs count]; 100 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didFinishWithTotalCount:skippedCount:)]) { 101 | [self.delegate imagePrefetcher:self 102 | didFinishWithTotalCount:(total - self.skippedCount) 103 | skippedCount:self.skippedCount 104 | ]; 105 | } 106 | } 107 | 108 | - (void)prefetchURLs:(NSArray *)urls { 109 | [self prefetchURLs:urls progress:nil completed:nil]; 110 | } 111 | 112 | - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock { 113 | [self cancelPrefetching]; // Prevent duplicate prefetch request 114 | self.startedTime = CFAbsoluteTimeGetCurrent(); 115 | self.prefetchURLs = urls; 116 | self.completionBlock = completionBlock; 117 | self.progressBlock = progressBlock; 118 | 119 | if (urls.count == 0) { 120 | if (completionBlock) { 121 | completionBlock(0,0); 122 | } 123 | } else { 124 | // Starts prefetching from the very first image on the list with the max allowed concurrency 125 | NSUInteger listCount = self.prefetchURLs.count; 126 | for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) { 127 | [self startPrefetchingAtIndex:i]; 128 | } 129 | } 130 | } 131 | 132 | - (void)cancelPrefetching { 133 | self.prefetchURLs = nil; 134 | self.skippedCount = 0; 135 | self.requestedCount = 0; 136 | self.finishedCount = 0; 137 | [self.manager cancelAll]; 138 | } 139 | 140 | @end 141 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/UIButton+WebCache.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "UIButton+WebCache.h" 10 | #import "objc/runtime.h" 11 | #import "UIView+WebCacheOperation.h" 12 | 13 | static char imageURLStorageKey; 14 | 15 | @implementation UIButton (WebCache) 16 | 17 | - (NSURL *)sd_currentImageURL { 18 | NSURL *url = self.imageURLStorage[@(self.state)]; 19 | 20 | if (!url) { 21 | url = self.imageURLStorage[@(UIControlStateNormal)]; 22 | } 23 | 24 | return url; 25 | } 26 | 27 | - (NSURL *)sd_imageURLForState:(UIControlState)state { 28 | return self.imageURLStorage[@(state)]; 29 | } 30 | 31 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state { 32 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; 33 | } 34 | 35 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { 36 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; 37 | } 38 | 39 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { 40 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; 41 | } 42 | 43 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock { 44 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock]; 45 | } 46 | 47 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { 48 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock]; 49 | } 50 | 51 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { 52 | 53 | [self setImage:placeholder forState:state]; 54 | [self sd_cancelImageLoadForState:state]; 55 | 56 | if (!url) { 57 | [self.imageURLStorage removeObjectForKey:@(state)]; 58 | 59 | dispatch_main_async_safe(^{ 60 | if (completedBlock) { 61 | NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; 62 | completedBlock(nil, error, SDImageCacheTypeNone, url); 63 | } 64 | }); 65 | 66 | return; 67 | } 68 | 69 | self.imageURLStorage[@(state)] = url; 70 | 71 | __weak __typeof(self)wself = self; 72 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 73 | if (!wself) return; 74 | dispatch_main_sync_safe(^{ 75 | __strong UIButton *sself = wself; 76 | if (!sself) return; 77 | if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock) 78 | { 79 | completedBlock(image, error, cacheType, url); 80 | return; 81 | } 82 | else if (image) { 83 | [sself setImage:image forState:state]; 84 | } 85 | if (completedBlock && finished) { 86 | completedBlock(image, error, cacheType, url); 87 | } 88 | }); 89 | }]; 90 | [self sd_setImageLoadOperation:operation forState:state]; 91 | } 92 | 93 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state { 94 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; 95 | } 96 | 97 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { 98 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; 99 | } 100 | 101 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { 102 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; 103 | } 104 | 105 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock { 106 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock]; 107 | } 108 | 109 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { 110 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock]; 111 | } 112 | 113 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { 114 | [self sd_cancelBackgroundImageLoadForState:state]; 115 | 116 | [self setBackgroundImage:placeholder forState:state]; 117 | 118 | if (url) { 119 | __weak __typeof(self)wself = self; 120 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 121 | if (!wself) return; 122 | dispatch_main_sync_safe(^{ 123 | __strong UIButton *sself = wself; 124 | if (!sself) return; 125 | if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock) 126 | { 127 | completedBlock(image, error, cacheType, url); 128 | return; 129 | } 130 | else if (image) { 131 | [sself setBackgroundImage:image forState:state]; 132 | } 133 | if (completedBlock && finished) { 134 | completedBlock(image, error, cacheType, url); 135 | } 136 | }); 137 | }]; 138 | [self sd_setBackgroundImageLoadOperation:operation forState:state]; 139 | } else { 140 | dispatch_main_async_safe(^{ 141 | NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; 142 | if (completedBlock) { 143 | completedBlock(nil, error, SDImageCacheTypeNone, url); 144 | } 145 | }); 146 | } 147 | } 148 | 149 | - (void)sd_setImageLoadOperation:(id)operation forState:(UIControlState)state { 150 | [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; 151 | } 152 | 153 | - (void)sd_cancelImageLoadForState:(UIControlState)state { 154 | [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; 155 | } 156 | 157 | - (void)sd_setBackgroundImageLoadOperation:(id)operation forState:(UIControlState)state { 158 | [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; 159 | } 160 | 161 | - (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state { 162 | [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; 163 | } 164 | 165 | - (NSMutableDictionary *)imageURLStorage { 166 | NSMutableDictionary *storage = objc_getAssociatedObject(self, &imageURLStorageKey); 167 | if (!storage) 168 | { 169 | storage = [NSMutableDictionary dictionary]; 170 | objc_setAssociatedObject(self, &imageURLStorageKey, storage, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 171 | } 172 | 173 | return storage; 174 | } 175 | 176 | @end 177 | 178 | 179 | @implementation UIButton (WebCacheDeprecated) 180 | 181 | - (NSURL *)currentImageURL { 182 | return [self sd_currentImageURL]; 183 | } 184 | 185 | - (NSURL *)imageURLForState:(UIControlState)state { 186 | return [self sd_imageURLForState:state]; 187 | } 188 | 189 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state { 190 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; 191 | } 192 | 193 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { 194 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; 195 | } 196 | 197 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { 198 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; 199 | } 200 | 201 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock { 202 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 203 | if (completedBlock) { 204 | completedBlock(image, error, cacheType); 205 | } 206 | }]; 207 | } 208 | 209 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { 210 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 211 | if (completedBlock) { 212 | completedBlock(image, error, cacheType); 213 | } 214 | }]; 215 | } 216 | 217 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { 218 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 219 | if (completedBlock) { 220 | completedBlock(image, error, cacheType); 221 | } 222 | }]; 223 | } 224 | 225 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state { 226 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; 227 | } 228 | 229 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { 230 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; 231 | } 232 | 233 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { 234 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; 235 | } 236 | 237 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock { 238 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 239 | if (completedBlock) { 240 | completedBlock(image, error, cacheType); 241 | } 242 | }]; 243 | } 244 | 245 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { 246 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 247 | if (completedBlock) { 248 | completedBlock(image, error, cacheType); 249 | } 250 | }]; 251 | } 252 | 253 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { 254 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 255 | if (completedBlock) { 256 | completedBlock(image, error, cacheType); 257 | } 258 | }]; 259 | } 260 | 261 | - (void)cancelCurrentImageLoad { 262 | // in a backwards compatible manner, cancel for current state 263 | [self sd_cancelImageLoadForState:self.state]; 264 | } 265 | 266 | - (void)cancelBackgroundImageLoadForState:(UIControlState)state { 267 | [self sd_cancelBackgroundImageLoadForState:state]; 268 | } 269 | 270 | @end 271 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/UIImage+GIF.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+GIF.h 3 | // LBGIFImage 4 | // 5 | // Created by Laurin Brandner on 06.01.12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (GIF) 12 | 13 | + (UIImage *)sd_animatedGIFNamed:(NSString *)name; 14 | 15 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data; 16 | 17 | - (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/UIImage+GIF.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+GIF.m 3 | // LBGIFImage 4 | // 5 | // Created by Laurin Brandner on 06.01.12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "UIImage+GIF.h" 10 | #import 11 | 12 | @implementation UIImage (GIF) 13 | 14 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data { 15 | if (!data) { 16 | return nil; 17 | } 18 | 19 | CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); 20 | 21 | size_t count = CGImageSourceGetCount(source); 22 | 23 | UIImage *animatedImage; 24 | 25 | if (count <= 1) { 26 | animatedImage = [[UIImage alloc] initWithData:data]; 27 | } 28 | else { 29 | NSMutableArray *images = [NSMutableArray array]; 30 | 31 | NSTimeInterval duration = 0.0f; 32 | 33 | for (size_t i = 0; i < count; i++) { 34 | CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL); 35 | if (!image) { 36 | continue; 37 | } 38 | 39 | duration += [self sd_frameDurationAtIndex:i source:source]; 40 | 41 | [images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]]; 42 | 43 | CGImageRelease(image); 44 | } 45 | 46 | if (!duration) { 47 | duration = (1.0f / 10.0f) * count; 48 | } 49 | 50 | animatedImage = [UIImage animatedImageWithImages:images duration:duration]; 51 | } 52 | 53 | CFRelease(source); 54 | 55 | return animatedImage; 56 | } 57 | 58 | + (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source { 59 | float frameDuration = 0.1f; 60 | CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil); 61 | NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties; 62 | NSDictionary *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary]; 63 | 64 | NSNumber *delayTimeUnclampedProp = gifProperties[(NSString *)kCGImagePropertyGIFUnclampedDelayTime]; 65 | if (delayTimeUnclampedProp) { 66 | frameDuration = [delayTimeUnclampedProp floatValue]; 67 | } 68 | else { 69 | 70 | NSNumber *delayTimeProp = gifProperties[(NSString *)kCGImagePropertyGIFDelayTime]; 71 | if (delayTimeProp) { 72 | frameDuration = [delayTimeProp floatValue]; 73 | } 74 | } 75 | 76 | // Many annoying ads specify a 0 duration to make an image flash as quickly as possible. 77 | // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify 78 | // a duration of <= 10 ms. See and 79 | // for more information. 80 | 81 | if (frameDuration < 0.011f) { 82 | frameDuration = 0.100f; 83 | } 84 | 85 | CFRelease(cfFrameProperties); 86 | return frameDuration; 87 | } 88 | 89 | + (UIImage *)sd_animatedGIFNamed:(NSString *)name { 90 | CGFloat scale = [UIScreen mainScreen].scale; 91 | 92 | if (scale > 1.0f) { 93 | NSString *retinaPath = [[NSBundle mainBundle] pathForResource:[name stringByAppendingString:@"@2x"] ofType:@"gif"]; 94 | 95 | NSData *data = [NSData dataWithContentsOfFile:retinaPath]; 96 | 97 | if (data) { 98 | return [UIImage sd_animatedGIFWithData:data]; 99 | } 100 | 101 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; 102 | 103 | data = [NSData dataWithContentsOfFile:path]; 104 | 105 | if (data) { 106 | return [UIImage sd_animatedGIFWithData:data]; 107 | } 108 | 109 | return [UIImage imageNamed:name]; 110 | } 111 | else { 112 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; 113 | 114 | NSData *data = [NSData dataWithContentsOfFile:path]; 115 | 116 | if (data) { 117 | return [UIImage sd_animatedGIFWithData:data]; 118 | } 119 | 120 | return [UIImage imageNamed:name]; 121 | } 122 | } 123 | 124 | - (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size { 125 | if (CGSizeEqualToSize(self.size, size) || CGSizeEqualToSize(size, CGSizeZero)) { 126 | return self; 127 | } 128 | 129 | CGSize scaledSize = size; 130 | CGPoint thumbnailPoint = CGPointZero; 131 | 132 | CGFloat widthFactor = size.width / self.size.width; 133 | CGFloat heightFactor = size.height / self.size.height; 134 | CGFloat scaleFactor = (widthFactor > heightFactor) ? widthFactor : heightFactor; 135 | scaledSize.width = self.size.width * scaleFactor; 136 | scaledSize.height = self.size.height * scaleFactor; 137 | 138 | if (widthFactor > heightFactor) { 139 | thumbnailPoint.y = (size.height - scaledSize.height) * 0.5; 140 | } 141 | else if (widthFactor < heightFactor) { 142 | thumbnailPoint.x = (size.width - scaledSize.width) * 0.5; 143 | } 144 | 145 | NSMutableArray *scaledImages = [NSMutableArray array]; 146 | 147 | for (UIImage *image in self.images) { 148 | UIGraphicsBeginImageContextWithOptions(size, NO, 0.0); 149 | 150 | [image drawInRect:CGRectMake(thumbnailPoint.x, thumbnailPoint.y, scaledSize.width, scaledSize.height)]; 151 | UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 152 | 153 | [scaledImages addObject:newImage]; 154 | 155 | UIGraphicsEndImageContext(); 156 | } 157 | 158 | return [UIImage animatedImageWithImages:scaledImages duration:self.duration]; 159 | } 160 | 161 | @end 162 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+MultiFormat.h 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (MultiFormat) 12 | 13 | + (UIImage *)sd_imageWithData:(NSData *)data; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+MultiFormat.m 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import "UIImage+MultiFormat.h" 10 | #import "UIImage+GIF.h" 11 | #import "NSData+ImageContentType.h" 12 | #import 13 | 14 | #ifdef SD_WEBP 15 | #import "UIImage+WebP.h" 16 | #endif 17 | 18 | @implementation UIImage (MultiFormat) 19 | 20 | + (UIImage *)sd_imageWithData:(NSData *)data { 21 | if (!data) { 22 | return nil; 23 | } 24 | 25 | UIImage *image; 26 | NSString *imageContentType = [NSData sd_contentTypeForImageData:data]; 27 | if ([imageContentType isEqualToString:@"image/gif"]) { 28 | image = [UIImage sd_animatedGIFWithData:data]; 29 | } 30 | #ifdef SD_WEBP 31 | else if ([imageContentType isEqualToString:@"image/webp"]) 32 | { 33 | image = [UIImage sd_imageWithWebPData:data]; 34 | } 35 | #endif 36 | else { 37 | image = [[UIImage alloc] initWithData:data]; 38 | UIImageOrientation orientation = [self sd_imageOrientationFromImageData:data]; 39 | if (orientation != UIImageOrientationUp) { 40 | image = [UIImage imageWithCGImage:image.CGImage 41 | scale:image.scale 42 | orientation:orientation]; 43 | } 44 | } 45 | 46 | 47 | return image; 48 | } 49 | 50 | 51 | +(UIImageOrientation)sd_imageOrientationFromImageData:(NSData *)imageData { 52 | UIImageOrientation result = UIImageOrientationUp; 53 | CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL); 54 | if (imageSource) { 55 | CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); 56 | if (properties) { 57 | CFTypeRef val; 58 | int exifOrientation; 59 | val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation); 60 | if (val) { 61 | CFNumberGetValue(val, kCFNumberIntType, &exifOrientation); 62 | result = [self sd_exifOrientationToiOSOrientation:exifOrientation]; 63 | } // else - if it's not set it remains at up 64 | CFRelease((CFTypeRef) properties); 65 | } else { 66 | //NSLog(@"NO PROPERTIES, FAIL"); 67 | } 68 | CFRelease(imageSource); 69 | } 70 | return result; 71 | } 72 | 73 | #pragma mark EXIF orientation tag converter 74 | // Convert an EXIF image orientation to an iOS one. 75 | // reference see here: http://sylvana.net/jpegcrop/exif_orientation.html 76 | + (UIImageOrientation) sd_exifOrientationToiOSOrientation:(int)exifOrientation { 77 | UIImageOrientation orientation = UIImageOrientationUp; 78 | switch (exifOrientation) { 79 | case 1: 80 | orientation = UIImageOrientationUp; 81 | break; 82 | 83 | case 3: 84 | orientation = UIImageOrientationDown; 85 | break; 86 | 87 | case 8: 88 | orientation = UIImageOrientationLeft; 89 | break; 90 | 91 | case 6: 92 | orientation = UIImageOrientationRight; 93 | break; 94 | 95 | case 2: 96 | orientation = UIImageOrientationUpMirrored; 97 | break; 98 | 99 | case 4: 100 | orientation = UIImageOrientationDownMirrored; 101 | break; 102 | 103 | case 5: 104 | orientation = UIImageOrientationLeftMirrored; 105 | break; 106 | 107 | case 7: 108 | orientation = UIImageOrientationRightMirrored; 109 | break; 110 | default: 111 | break; 112 | } 113 | return orientation; 114 | } 115 | 116 | 117 | 118 | @end 119 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | #import "SDWebImageManager.h" 12 | 13 | /** 14 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView for highlighted state. 15 | */ 16 | @interface UIImageView (HighlightedWebCache) 17 | 18 | /** 19 | * Set the imageView `highlightedImage` with an `url`. 20 | * 21 | * The download is asynchronous and cached. 22 | * 23 | * @param url The url for the image. 24 | */ 25 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url; 26 | 27 | /** 28 | * Set the imageView `highlightedImage` with an `url` and custom options. 29 | * 30 | * The download is asynchronous and cached. 31 | * 32 | * @param url The url for the image. 33 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 34 | */ 35 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options; 36 | 37 | /** 38 | * Set the imageView `highlightedImage` with an `url`. 39 | * 40 | * The download is asynchronous and cached. 41 | * 42 | * @param url The url for the image. 43 | * @param completedBlock A block called when operation has been completed. This block has no return value 44 | * and takes the requested UIImage as first parameter. In case of error the image parameter 45 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 46 | * indicating if the image was retrieved from the local cache or from the network. 47 | * The fourth parameter is the original image url. 48 | */ 49 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; 50 | 51 | /** 52 | * Set the imageView `highlightedImage` with an `url` and custom options. 53 | * 54 | * The download is asynchronous and cached. 55 | * 56 | * @param url The url for the image. 57 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 58 | * @param completedBlock A block called when operation has been completed. This block has no return value 59 | * and takes the requested UIImage as first parameter. In case of error the image parameter 60 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 61 | * indicating if the image was retrieved from the local cache or from the network. 62 | * The fourth parameter is the original image url. 63 | */ 64 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; 65 | 66 | /** 67 | * Set the imageView `highlightedImage` with an `url` and custom options. 68 | * 69 | * The download is asynchronous and cached. 70 | * 71 | * @param url The url for the image. 72 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 73 | * @param progressBlock A block called while image is downloading 74 | * @param completedBlock A block called when operation has been completed. This block has no return value 75 | * and takes the requested UIImage as first parameter. In case of error the image parameter 76 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 77 | * indicating if the image was retrieved from the local cache or from the network. 78 | * The fourth parameter is the original image url. 79 | */ 80 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; 81 | 82 | /** 83 | * Cancel the current download 84 | */ 85 | - (void)sd_cancelCurrentHighlightedImageLoad; 86 | 87 | @end 88 | 89 | 90 | @interface UIImageView (HighlightedWebCacheDeprecated) 91 | 92 | - (void)setHighlightedImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:`"); 93 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:`"); 94 | - (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:completed:`"); 95 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:completed:`"); 96 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:progress:completed:`"); 97 | 98 | - (void)cancelCurrentHighlightedImageLoad __deprecated_msg("Use `sd_cancelCurrentHighlightedImageLoad`"); 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "UIImageView+HighlightedWebCache.h" 10 | #import "UIView+WebCacheOperation.h" 11 | 12 | #define UIImageViewHighlightedWebCacheOperationKey @"highlightedImage" 13 | 14 | @implementation UIImageView (HighlightedWebCache) 15 | 16 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url { 17 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; 18 | } 19 | 20 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { 21 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; 22 | } 23 | 24 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock { 25 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:completedBlock]; 26 | } 27 | 28 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { 29 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock]; 30 | } 31 | 32 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { 33 | [self sd_cancelCurrentHighlightedImageLoad]; 34 | 35 | if (url) { 36 | __weak __typeof(self)wself = self; 37 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 38 | if (!wself) return; 39 | dispatch_main_sync_safe (^ 40 | { 41 | if (!wself) return; 42 | if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock) 43 | { 44 | completedBlock(image, error, cacheType, url); 45 | return; 46 | } 47 | else if (image) { 48 | wself.highlightedImage = image; 49 | [wself setNeedsLayout]; 50 | } 51 | if (completedBlock && finished) { 52 | completedBlock(image, error, cacheType, url); 53 | } 54 | }); 55 | }]; 56 | [self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey]; 57 | } else { 58 | dispatch_main_async_safe(^{ 59 | NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; 60 | if (completedBlock) { 61 | completedBlock(nil, error, SDImageCacheTypeNone, url); 62 | } 63 | }); 64 | } 65 | } 66 | 67 | - (void)sd_cancelCurrentHighlightedImageLoad { 68 | [self sd_cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey]; 69 | } 70 | 71 | @end 72 | 73 | 74 | @implementation UIImageView (HighlightedWebCacheDeprecated) 75 | 76 | - (void)setHighlightedImageWithURL:(NSURL *)url { 77 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; 78 | } 79 | 80 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { 81 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; 82 | } 83 | 84 | - (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock { 85 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 86 | if (completedBlock) { 87 | completedBlock(image, error, cacheType); 88 | } 89 | }]; 90 | } 91 | 92 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { 93 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 94 | if (completedBlock) { 95 | completedBlock(image, error, cacheType); 96 | } 97 | }]; 98 | } 99 | 100 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { 101 | [self sd_setHighlightedImageWithURL:url options:0 progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 102 | if (completedBlock) { 103 | completedBlock(image, error, cacheType); 104 | } 105 | }]; 106 | } 107 | 108 | - (void)cancelCurrentHighlightedImageLoad { 109 | [self sd_cancelCurrentHighlightedImageLoad]; 110 | } 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | #import "SDWebImageManager.h" 11 | 12 | /** 13 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView. 14 | * 15 | * Usage with a UITableViewCell sub-class: 16 | * 17 | * @code 18 | 19 | #import 20 | 21 | ... 22 | 23 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 24 | { 25 | static NSString *MyIdentifier = @"MyIdentifier"; 26 | 27 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 28 | 29 | if (cell == nil) { 30 | cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] 31 | autorelease]; 32 | } 33 | 34 | // Here we use the provided sd_setImageWithURL: method to load the web image 35 | // Ensure you use a placeholder image otherwise cells will be initialized with no image 36 | [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"] 37 | placeholderImage:[UIImage imageNamed:@"placeholder"]]; 38 | 39 | cell.textLabel.text = @"My Text"; 40 | return cell; 41 | } 42 | 43 | * @endcode 44 | */ 45 | @interface UIImageView (WebCache) 46 | 47 | /** 48 | * Get the current image URL. 49 | * 50 | * Note that because of the limitations of categories this property can get out of sync 51 | * if you use sd_setImage: directly. 52 | */ 53 | - (NSURL *)sd_imageURL; 54 | 55 | /** 56 | * Set the imageView `image` with an `url`. 57 | * 58 | * The download is asynchronous and cached. 59 | * 60 | * @param url The url for the image. 61 | */ 62 | - (void)sd_setImageWithURL:(NSURL *)url; 63 | 64 | /** 65 | * Set the imageView `image` with an `url` and a placeholder. 66 | * 67 | * The download is asynchronous and cached. 68 | * 69 | * @param url The url for the image. 70 | * @param placeholder The image to be set initially, until the image request finishes. 71 | * @see sd_setImageWithURL:placeholderImage:options: 72 | */ 73 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder; 74 | 75 | /** 76 | * Set the imageView `image` with an `url`, placeholder and custom options. 77 | * 78 | * The download is asynchronous and cached. 79 | * 80 | * @param url The url for the image. 81 | * @param placeholder The image to be set initially, until the image request finishes. 82 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 83 | */ 84 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; 85 | 86 | /** 87 | * Set the imageView `image` with an `url`. 88 | * 89 | * The download is asynchronous and cached. 90 | * 91 | * @param url The url for the image. 92 | * @param completedBlock A block called when operation has been completed. This block has no return value 93 | * and takes the requested UIImage as first parameter. In case of error the image parameter 94 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 95 | * indicating if the image was retrieved from the local cache or from the network. 96 | * The fourth parameter is the original image url. 97 | */ 98 | - (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; 99 | 100 | /** 101 | * Set the imageView `image` with an `url`, placeholder. 102 | * 103 | * The download is asynchronous and cached. 104 | * 105 | * @param url The url for the image. 106 | * @param placeholder The image to be set initially, until the image request finishes. 107 | * @param completedBlock A block called when operation has been completed. This block has no return value 108 | * and takes the requested UIImage as first parameter. In case of error the image parameter 109 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 110 | * indicating if the image was retrieved from the local cache or from the network. 111 | * The fourth parameter is the original image url. 112 | */ 113 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; 114 | 115 | /** 116 | * Set the imageView `image` with an `url`, placeholder and custom options. 117 | * 118 | * The download is asynchronous and cached. 119 | * 120 | * @param url The url for the image. 121 | * @param placeholder The image to be set initially, until the image request finishes. 122 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 123 | * @param completedBlock A block called when operation has been completed. This block has no return value 124 | * and takes the requested UIImage as first parameter. In case of error the image parameter 125 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 126 | * indicating if the image was retrieved from the local cache or from the network. 127 | * The fourth parameter is the original image url. 128 | */ 129 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; 130 | 131 | /** 132 | * Set the imageView `image` with an `url`, placeholder and custom options. 133 | * 134 | * The download is asynchronous and cached. 135 | * 136 | * @param url The url for the image. 137 | * @param placeholder The image to be set initially, until the image request finishes. 138 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 139 | * @param progressBlock A block called while image is downloading 140 | * @param completedBlock A block called when operation has been completed. This block has no return value 141 | * and takes the requested UIImage as first parameter. In case of error the image parameter 142 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 143 | * indicating if the image was retrieved from the local cache or from the network. 144 | * The fourth parameter is the original image url. 145 | */ 146 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; 147 | 148 | /** 149 | * Set the imageView `image` with an `url` and optionally a placeholder image. 150 | * 151 | * The download is asynchronous and cached. 152 | * 153 | * @param url The url for the image. 154 | * @param placeholder The image to be set initially, until the image request finishes. 155 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 156 | * @param progressBlock A block called while image is downloading 157 | * @param completedBlock A block called when operation has been completed. This block has no return value 158 | * and takes the requested UIImage as first parameter. In case of error the image parameter 159 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 160 | * indicating if the image was retrieved from the local cache or from the network. 161 | * The fourth parameter is the original image url. 162 | */ 163 | - (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; 164 | 165 | /** 166 | * Download an array of images and starts them in an animation loop 167 | * 168 | * @param arrayOfURLs An array of NSURL 169 | */ 170 | - (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs; 171 | 172 | /** 173 | * Cancel the current download 174 | */ 175 | - (void)sd_cancelCurrentImageLoad; 176 | 177 | - (void)sd_cancelCurrentAnimationImagesLoad; 178 | 179 | /** 180 | * Show activity UIActivityIndicatorView 181 | */ 182 | - (void)setShowActivityIndicatorView:(BOOL)show; 183 | 184 | /** 185 | * set desired UIActivityIndicatorViewStyle 186 | * 187 | * @param style The style of the UIActivityIndicatorView 188 | */ 189 | - (void)setIndicatorStyle:(UIActivityIndicatorViewStyle)style; 190 | 191 | @end 192 | 193 | 194 | @interface UIImageView (WebCacheDeprecated) 195 | 196 | - (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`"); 197 | 198 | - (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`"); 199 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`"); 200 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options`"); 201 | 202 | - (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:completed:`"); 203 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:completed:`"); 204 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`"); 205 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:progress:completed:`"); 206 | 207 | - (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url andPlaceholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithPreviousCachedImageWithURL:placeholderImage:options:progress:completed:`"); 208 | 209 | - (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs __deprecated_msg("Use `sd_setAnimationImagesWithURLs:`"); 210 | 211 | - (void)cancelCurrentArrayLoad __deprecated_msg("Use `sd_cancelCurrentAnimationImagesLoad`"); 212 | 213 | - (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelCurrentImageLoad`"); 214 | 215 | @end 216 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageManager.h" 11 | 12 | @interface UIView (WebCacheOperation) 13 | 14 | /** 15 | * Set the image load operation (storage in a UIView based dictionary) 16 | * 17 | * @param operation the operation 18 | * @param key key for storing the operation 19 | */ 20 | - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key; 21 | 22 | /** 23 | * Cancel all operations for the current UIView and key 24 | * 25 | * @param key key for identifying the operations 26 | */ 27 | - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key; 28 | 29 | /** 30 | * Just remove the operations corresponding to the current UIView and key without cancelling them 31 | * 32 | * @param key key for identifying the operations 33 | */ 34 | - (void)sd_removeImageLoadOperationWithKey:(NSString *)key; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "UIView+WebCacheOperation.h" 10 | #import "objc/runtime.h" 11 | 12 | static char loadOperationKey; 13 | 14 | @implementation UIView (WebCacheOperation) 15 | 16 | - (NSMutableDictionary *)operationDictionary { 17 | NSMutableDictionary *operations = objc_getAssociatedObject(self, &loadOperationKey); 18 | if (operations) { 19 | return operations; 20 | } 21 | operations = [NSMutableDictionary dictionary]; 22 | objc_setAssociatedObject(self, &loadOperationKey, operations, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 23 | return operations; 24 | } 25 | 26 | - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key { 27 | [self sd_cancelImageLoadOperationWithKey:key]; 28 | NSMutableDictionary *operationDictionary = [self operationDictionary]; 29 | [operationDictionary setObject:operation forKey:key]; 30 | } 31 | 32 | - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key { 33 | // Cancel in progress downloader from queue 34 | NSMutableDictionary *operationDictionary = [self operationDictionary]; 35 | id operations = [operationDictionary objectForKey:key]; 36 | if (operations) { 37 | if ([operations isKindOfClass:[NSArray class]]) { 38 | for (id operation in operations) { 39 | if (operation) { 40 | [operation cancel]; 41 | } 42 | } 43 | } else if ([operations conformsToProtocol:@protocol(SDWebImageOperation)]){ 44 | [(id) operations cancel]; 45 | } 46 | [operationDictionary removeObjectForKey:key]; 47 | } 48 | } 49 | 50 | - (void)sd_removeImageLoadOperationWithKey:(NSString *)key { 51 | NSMutableDictionary *operationDictionary = [self operationDictionary]; 52 | [operationDictionary removeObjectForKey:key]; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Target Support Files/MBProgressHUD/MBProgressHUD-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_MBProgressHUD : NSObject 3 | @end 4 | @implementation PodsDummy_MBProgressHUD 5 | @end 6 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Target Support Files/MBProgressHUD/MBProgressHUD-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Target Support Files/MBProgressHUD/MBProgressHUD.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/MBProgressHUD 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/MBProgressHUD" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MBProgressHUD" "${PODS_ROOT}/Headers/Public/SDWebImage" 4 | OTHER_LDFLAGS = -framework "CoreGraphics" -framework "QuartzCore" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Target Support Files/Pods-MJPhotoBrowserDemo/Pods-MJPhotoBrowserDemo-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## MBProgressHUD 5 | 6 | Copyright © 2009-2016 Matej Bukovinski 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | ## SDWebImage 27 | 28 | Copyright (c) 2016 Olivier Poitrey rs@dailymotion.com 29 | 30 | Permission is hereby granted, free of charge, to any person obtaining a copy 31 | of this software and associated documentation files (the "Software"), to deal 32 | in the Software without restriction, including without limitation the rights 33 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 34 | copies of the Software, and to permit persons to whom the Software is furnished 35 | to do so, subject to the following conditions: 36 | 37 | The above copyright notice and this permission notice shall be included in all 38 | copies or substantial portions of the Software. 39 | 40 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 41 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 42 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 43 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 44 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 45 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 46 | THE SOFTWARE. 47 | 48 | 49 | Generated by CocoaPods - https://cocoapods.org 50 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Target Support Files/Pods-MJPhotoBrowserDemo/Pods-MJPhotoBrowserDemo-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright © 2009-2016 Matej Bukovinski 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | License 37 | MIT 38 | Title 39 | MBProgressHUD 40 | Type 41 | PSGroupSpecifier 42 | 43 | 44 | FooterText 45 | Copyright (c) 2016 Olivier Poitrey rs@dailymotion.com 46 | 47 | Permission is hereby granted, free of charge, to any person obtaining a copy 48 | of this software and associated documentation files (the "Software"), to deal 49 | in the Software without restriction, including without limitation the rights 50 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 51 | copies of the Software, and to permit persons to whom the Software is furnished 52 | to do so, subject to the following conditions: 53 | 54 | The above copyright notice and this permission notice shall be included in all 55 | copies or substantial portions of the Software. 56 | 57 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 58 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 59 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 60 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 61 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 62 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 63 | THE SOFTWARE. 64 | 65 | 66 | License 67 | MIT 68 | Title 69 | SDWebImage 70 | Type 71 | PSGroupSpecifier 72 | 73 | 74 | FooterText 75 | Generated by CocoaPods - https://cocoapods.org 76 | Title 77 | 78 | Type 79 | PSGroupSpecifier 80 | 81 | 82 | StringsTable 83 | Acknowledgements 84 | Title 85 | Acknowledgements 86 | 87 | 88 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Target Support Files/Pods-MJPhotoBrowserDemo/Pods-MJPhotoBrowserDemo-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_MJPhotoBrowserDemo : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_MJPhotoBrowserDemo 5 | @end 6 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Target Support Files/Pods-MJPhotoBrowserDemo/Pods-MJPhotoBrowserDemo-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Target Support Files/Pods-MJPhotoBrowserDemo/Pods-MJPhotoBrowserDemo-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | *) 22 | TARGET_DEVICE_ARGS="--target-device mac" 23 | ;; 24 | esac 25 | 26 | install_resource() 27 | { 28 | if [[ "$1" = /* ]] ; then 29 | RESOURCE_PATH="$1" 30 | else 31 | RESOURCE_PATH="${PODS_ROOT}/$1" 32 | fi 33 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 34 | cat << EOM 35 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 36 | EOM 37 | exit 1 38 | fi 39 | case $RESOURCE_PATH in 40 | *.storyboard) 41 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 42 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 43 | ;; 44 | *.xib) 45 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 46 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 47 | ;; 48 | *.framework) 49 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 50 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 51 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 52 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 53 | ;; 54 | *.xcdatamodel) 55 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 56 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 57 | ;; 58 | *.xcdatamodeld) 59 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 60 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 61 | ;; 62 | *.xcmappingmodel) 63 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 64 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 65 | ;; 66 | *.xcassets) 67 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 68 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 69 | ;; 70 | *) 71 | echo "$RESOURCE_PATH" 72 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 73 | ;; 74 | esac 75 | } 76 | 77 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 78 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 79 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 80 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 81 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 82 | fi 83 | rm -f "$RESOURCES_TO_COPY" 84 | 85 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 86 | then 87 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 88 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 89 | while read line; do 90 | if [[ $line != "${PODS_ROOT}*" ]]; then 91 | XCASSET_FILES+=("$line") 92 | fi 93 | done <<<"$OTHER_XCASSETS" 94 | 95 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 96 | fi 97 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Target Support Files/Pods-MJPhotoBrowserDemo/Pods-MJPhotoBrowserDemo.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MBProgressHUD" "${PODS_ROOT}/Headers/Public/SDWebImage" 4 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/MBProgressHUD" "$PODS_CONFIGURATION_BUILD_DIR/SDWebImage" 5 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/MBProgressHUD" -isystem "${PODS_ROOT}/Headers/Public/SDWebImage" 6 | OTHER_LDFLAGS = $(inherited) -ObjC -l"MBProgressHUD" -l"SDWebImage" -framework "CoreGraphics" -framework "ImageIO" -framework "QuartzCore" 7 | PODS_BUILD_DIR = $BUILD_DIR 8 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Target Support Files/Pods-MJPhotoBrowserDemo/Pods-MJPhotoBrowserDemo.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MBProgressHUD" "${PODS_ROOT}/Headers/Public/SDWebImage" 4 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/MBProgressHUD" "$PODS_CONFIGURATION_BUILD_DIR/SDWebImage" 5 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/MBProgressHUD" -isystem "${PODS_ROOT}/Headers/Public/SDWebImage" 6 | OTHER_LDFLAGS = $(inherited) -ObjC -l"MBProgressHUD" -l"SDWebImage" -framework "CoreGraphics" -framework "ImageIO" -framework "QuartzCore" 7 | PODS_BUILD_DIR = $BUILD_DIR 8 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Target Support Files/SDWebImage/SDWebImage-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_SDWebImage : NSObject 3 | @end 4 | @implementation PodsDummy_SDWebImage 5 | @end 6 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /MJPhotoBrowserDemo/Pods/Target Support Files/SDWebImage/SDWebImage.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/SDWebImage 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/SDWebImage" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MBProgressHUD" "${PODS_ROOT}/Headers/Public/SDWebImage" 4 | OTHER_LDFLAGS = -framework "ImageIO" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MJPhotoBrowser高性能图片浏览器,支持本地图片、网络图片、gif图片 2 | ## 在MJPhotoBrowser源码的基础上修复了以下bug: 3 | ### 1.在放大图时会出现加载高清图的小圆圈progressView 表示进度。如果进入还未完成,点击图片意图隐藏此时的view时,会crash 4 | ### 2.图片放大时图片太靠近底部的问题 5 | ### 3.双击小图片手势冲突会闪动的问题 6 | ### 4.修复了双击图片可能会导致图片位移的问题 7 | ### 5.由于MBProgressHUD和SDWebImage的升级导致部分警告的问题 8 | 9 | ### 主要功能: 10 | 11 | ![Image text](https://raw.githubusercontent.com/coder-zwz/MJPhotoBrowser/master/screenshots/Simulator0.png) 12 | 13 | ![Image text](https://raw.githubusercontent.com/coder-zwz/MJPhotoBrowser/master/screenshots/Simulator3.png) 14 | 15 | #### 代码示例 16 | ```Objective-C 17 | 18 | - (void)viewDidLoad 19 | { 20 | [super viewDidLoad]; 21 | // 0.图片链接 22 | _urls = @[@"http://ww4.sinaimg.cn/thumbnail/7f8c1087gw1e9g06pc68ug20ag05y4qq.gif", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr0nly5j20pf0gygo6.jpg", @"http://ww4.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr1d0vyj20pf0gytcj.jpg", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr1xydcj20gy0o9q6s.jpg", @"http://ww2.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr2n1jjj20gy0o9tcc.jpg", @"http://ww2.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr39ht9j20gy0o6q74.jpg", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr3xvtlj20gy0obadv.jpg", @"http://ww4.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr4nndfj20gy0o9q6i.jpg", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr57tn9j20gy0obn0f.jpg"]; 23 | 24 | // 1.创建9个UIImageView 25 | UIImage *placeholder = [UIImage imageNamed:@"timeline_image_loading.png"]; 26 | CGFloat width = 80; 27 | CGFloat height = 80; 28 | CGFloat margin = 5; 29 | CGFloat startX = (self.view.frame.size.width - 3 * width - 2 * margin) * 0.5; 30 | CGFloat startY = 80; 31 | for (int i = 0; i<9; i++) { 32 | UIImageView *imageView = [[UIImageView alloc] init]; 33 | [self.view addSubview:imageView]; 34 | 35 | // 计算位置 36 | int row = i/3; 37 | int column = i%3; 38 | CGFloat x = startX + column * (width + margin); 39 | CGFloat y = startY + row * (height + margin); 40 | imageView.frame = CGRectMake(x, y, width, height); 41 | 42 | // 下载图片 43 | [imageView setImageURLStr:_urls[i] placeholder:placeholder]; 44 | 45 | // 事件监听 46 | imageView.tag = i; 47 | imageView.userInteractionEnabled = YES; 48 | [imageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImage:)]]; 49 | 50 | // 内容模式 51 | imageView.clipsToBounds = YES; 52 | imageView.contentMode = UIViewContentModeScaleAspectFill; 53 | } 54 | } 55 | 56 | - (void)tapImage:(UITapGestureRecognizer *)tap 57 | { 58 | NSInteger count = _urls.count; 59 | // 1.封装图片数据 60 | NSMutableArray *photos = [NSMutableArray arrayWithCapacity:count]; 61 | for (int i = 0; i