├── ADPageViewDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── ZXX.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── ADPageViewDemo.xcworkspace ├── contents.xcworkspacedata ├── xcshareddata │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── ZXX.xcuserdatad │ └── xcdebugger │ └── Breakpoints_v2.xcbkptlist ├── ADPageViewDemo ├── ADPage │ ├── ADPageView.h │ ├── ADPageView.m │ ├── ADPageViewController.h │ └── ADPageViewController.m ├── AppDelegate │ ├── AppDelegate.h │ └── AppDelegate.m ├── GuidePage │ ├── GuidePageView.h │ └── GuidePageView.m ├── Info.plist ├── Resours │ ├── Assets.xcassets │ │ ├── 1.imageset │ │ │ ├── 1.jpg │ │ │ └── Contents.json │ │ ├── 2.imageset │ │ │ ├── 3.jpg │ │ │ └── Contents.json │ │ ├── 3.imageset │ │ │ ├── 2.jpg │ │ │ └── Contents.json │ │ ├── 4.imageset │ │ │ ├── 4.jpg │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── cc40@2x.jpg │ │ │ ├── cc40@3x.jpg │ │ │ ├── cc60@2x.jpg │ │ │ └── cc60@3x.jpg │ │ ├── Contents.json │ │ └── LaunchImage.launchimage │ │ │ ├── Contents.json │ │ │ ├── mizhi1104@3x.png │ │ │ └── mizhi667@2x.png │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Header.h │ └── PrefixHeader.pch ├── Utils │ ├── Manager.h │ └── Manager.m ├── ViewController │ ├── ViewController.h │ └── ViewController.m └── main.m ├── ADPageViewDemoTests ├── ADPageViewDemoTests.m └── Info.plist ├── ADPageViewDemoUITests ├── ADPageViewDemoUITests.m └── Info.plist ├── Podfile ├── Podfile.lock ├── Pods ├── Manifest.lock ├── Pods.xcodeproj │ ├── project.pbxproj │ └── xcuserdata │ │ └── ZXX.xcuserdatad │ │ └── xcschemes │ │ ├── Pods-ADPageViewDemo.xcscheme │ │ ├── SDAutoLayout.xcscheme │ │ ├── SDWebImage.xcscheme │ │ └── xcschememanagement.plist ├── SDAutoLayout │ ├── LICENSE │ ├── README.md │ └── SDAutoLayoutDemo │ │ └── SDAutoLayout │ │ ├── SDAutoLayout.h │ │ ├── UITableView+SDAutoTableViewCellHeight.h │ │ ├── UITableView+SDAutoTableViewCellHeight.m │ │ ├── UIView+SDAutoLayout.h │ │ └── UIView+SDAutoLayout.m ├── SDWebImage │ ├── LICENSE │ ├── README.md │ └── SDWebImage │ │ ├── NSData+ImageContentType.h │ │ ├── NSData+ImageContentType.m │ │ ├── NSImage+WebCache.h │ │ ├── NSImage+WebCache.m │ │ ├── SDImageCache.h │ │ ├── SDImageCache.m │ │ ├── SDImageCacheConfig.h │ │ ├── SDImageCacheConfig.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+WebCache.h │ │ ├── UIView+WebCache.m │ │ ├── UIView+WebCacheOperation.h │ │ └── UIView+WebCacheOperation.m └── Target Support Files │ ├── Pods-ADPageViewDemo │ ├── Info.plist │ ├── Pods-ADPageViewDemo-acknowledgements.markdown │ ├── Pods-ADPageViewDemo-acknowledgements.plist │ ├── Pods-ADPageViewDemo-dummy.m │ ├── Pods-ADPageViewDemo-frameworks.sh │ ├── Pods-ADPageViewDemo-resources.sh │ ├── Pods-ADPageViewDemo-umbrella.h │ ├── Pods-ADPageViewDemo.debug.xcconfig │ ├── Pods-ADPageViewDemo.modulemap │ └── Pods-ADPageViewDemo.release.xcconfig │ ├── SDAutoLayout │ ├── Info.plist │ ├── SDAutoLayout-dummy.m │ ├── SDAutoLayout-prefix.pch │ ├── SDAutoLayout-umbrella.h │ ├── SDAutoLayout.modulemap │ └── SDAutoLayout.xcconfig │ └── SDWebImage │ ├── Info.plist │ ├── SDWebImage-dummy.m │ ├── SDWebImage-prefix.pch │ ├── SDWebImage-umbrella.h │ ├── SDWebImage.modulemap │ └── SDWebImage.xcconfig ├── README.md ├── show1.gif └── show2.gif /ADPageViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ADPageViewDemo.xcodeproj/xcuserdata/ZXX.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ADPageViewDemo.xcscheme 8 | 9 | orderHint 10 | 3 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ADPageViewDemo.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ADPageViewDemo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ADPageViewDemo.xcworkspace/xcuserdata/ZXX.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /ADPageViewDemo/ADPage/ADPageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // ADPageView.h 3 | // ADPageViewDemo 4 | // 5 | // Created by ZhangCc on 2017/10/18. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ADPageView : UIView 12 | 13 | /** 14 | 创建广告页面 15 | */ 16 | + (instancetype)showAdPageView; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ADPageViewDemo/ADPage/ADPageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // ADPageView.m 3 | // ADPageViewDemo 4 | // 5 | // Created by ZhangCc on 2017/10/18. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #import "ADPageView.h" 10 | static int const showTime = 3; 11 | static NSString *const adImageName = @"adImageName"; 12 | static NSString *const adUrl = @"adUrl"; 13 | 14 | @interface ADPageView () 15 | 16 | @property (nonatomic, strong) UIImageView *adView; 17 | @property (nonatomic, strong) UIButton *skipBtn; 18 | @property (nonatomic, strong) NSTimer *timer; 19 | @property (nonatomic, assign) NSInteger timeCount; 20 | 21 | //广告图片本地地址 22 | @property (nonatomic, copy) NSString *imagePath; 23 | //新广告图片URL 24 | @property (nonatomic, copy) NSString *imageUrl; 25 | //新广告URL 26 | @property (nonatomic, copy) NSString *adUrl; 27 | 28 | @end 29 | 30 | @implementation ADPageView 31 | 32 | static ADPageView *adPageView = nil; 33 | 34 | #pragma mark - Lazy methods 35 | - (NSTimer *)timer { 36 | if (!_timer) { 37 | _timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerDown) userInfo:nil repeats:YES]; 38 | } 39 | return _timer; 40 | } 41 | 42 | #pragma mark - Public methods 43 | + (instancetype)showAdPageView { 44 | adPageView = [[ADPageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH,SCREEN_HEIGHT)]; 45 | adPageView.backgroundColor = [UIColor whiteColor]; 46 | 47 | return adPageView; 48 | } 49 | 50 | #pragma mark - Init methods 51 | - (instancetype)initWithFrame:(CGRect)frame { 52 | if (self = [super initWithFrame:frame]) { 53 | //广告页 54 | _adView = [[UIImageView alloc] initWithFrame:frame]; 55 | _adView.userInteractionEnabled = YES; 56 | _adView.contentMode = UIViewContentModeScaleAspectFit; 57 | _adView.clipsToBounds = YES; 58 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushToAd)]; 59 | [_adView addGestureRecognizer:tap]; 60 | 61 | //跳过按钮 62 | _skipBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 63 | _skipBtn.backgroundColor = RGBAColor(38, 38, 38, 0.6); 64 | _skipBtn.layer.cornerRadius = 4; 65 | [_skipBtn setTitle:[NSString stringWithFormat:@"跳过%d",showTime] forState:UIControlStateNormal]; 66 | [_skipBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 67 | _skipBtn.titleLabel.font = [UIFont systemFontOfSize:15.0f]; 68 | [_skipBtn addTarget:self action:@selector(dismissAdView) forControlEvents:UIControlEventTouchUpInside]; 69 | 70 | [self addSubview:_adView]; 71 | [self addSubview:_skipBtn]; 72 | _skipBtn.sd_layout 73 | .widthIs(60) 74 | .heightIs(30) 75 | .topSpaceToView(self, 20) 76 | .rightSpaceToView(self, 20); 77 | 78 | [self showAdView]; 79 | } 80 | return self; 81 | } 82 | 83 | //展示广告 84 | - (void)showAdView { 85 | 86 | SDWebImageManager *imageManager = [SDWebImageManager sharedManager]; 87 | //先从sd缓存读取,有则显示 88 | NSString *imagePath = [[imageManager imageCache] defaultCachePathForKey:adImageName]; 89 | NSData * imageData = [NSData dataWithContentsOfFile:imagePath]; 90 | 91 | if (imageData) { 92 | [self adViewWithData:imageData]; 93 | } 94 | 95 | NSArray *imageArray = @[@"http://img.hb.aicdn.com/4cdbe766dc5a206da266a262ee87d9e5cf19eafb26a9d-xqBO2L_fw658", @"http://img.hb.aicdn.com/926c595bfb97b663077940b6598f63fa318dda092c174-hmqXI3_fw658", @"http://img.hb.aicdn.com/0e0d63ad054e9d48a3abb497c2c18e4b4293af4e134f6-CuXVbn_fw658", @"http://img.hb.aicdn.com/d534a50adbf8c0a6a886f28b7cc7148a723be6c42f511-9gvr0u_fw658"]; 96 | NSURL *url = [NSURL URLWithString:imageArray[arc4random() % imageArray.count]]; 97 | 98 | SDWebImageDownloader *downManager = [SDWebImageDownloader sharedDownloader]; 99 | //不管缓存是否存在图片,都重新请求新的图片,删除旧的,保存新的图片 100 | [imageManager cachedImageExistsForURL:url completion:^(BOOL isInCache) { 101 | //删除 102 | [[SDImageCache sharedImageCache] removeImageForKey:adImageName withCompletion:nil]; 103 | }]; 104 | [downManager downloadImageWithURL:url options:SDWebImageDownloaderUseNSURLCache progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) { 105 | //保存 106 | if (image && finished) { 107 | [[SDImageCache sharedImageCache] storeImage:image forKey:adImageName completion:nil]; 108 | } 109 | }]; 110 | } 111 | 112 | - (void)adViewWithData:(NSData *)data { 113 | [self startTimer]; 114 | UIWindow *window = [UIApplication sharedApplication].keyWindow; 115 | [window addSubview:self]; 116 | 117 | _adView.image = [UIImage imageWithData:data]; 118 | _adView.contentMode = UIViewContentModeScaleAspectFill; 119 | } 120 | 121 | 122 | //开始倒计时 123 | - (void)startTimer { 124 | _timeCount = showTime; 125 | [[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes]; 126 | } 127 | 128 | #pragma mark - Event response 129 | - (void)timerDown { 130 | _timeCount --; 131 | [_skipBtn setTitle:[NSString stringWithFormat:@"跳过%zd",_timeCount] forState:UIControlStateNormal]; 132 | if (_timeCount == 0) { 133 | [self dismissAdView]; 134 | } 135 | } 136 | 137 | 138 | - (void)pushToAd { 139 | [self dismissAdView]; 140 | [[NSNotificationCenter defaultCenter] postNotificationName:@"pushToAd" object:nil]; 141 | } 142 | 143 | //移除广告页 144 | - (void)dismissAdView { 145 | [self.timer invalidate]; 146 | self.timer = nil; 147 | 148 | [UIView animateWithDuration:0.3f animations:^{ 149 | self.alpha = 0.f; 150 | } completion:^(BOOL finished) { 151 | [self removeFromSuperview]; 152 | }]; 153 | } 154 | 155 | 156 | 157 | @end 158 | -------------------------------------------------------------------------------- /ADPageViewDemo/ADPage/ADPageViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ADPageViewController.h 3 | // ADPageViewDemo 4 | // 5 | // Created by ZhangCc on 2017/10/18. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ADPageViewController : UIViewController 12 | 13 | @property (nonatomic, copy) NSString *adUrl; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ADPageViewDemo/ADPage/ADPageViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ADPageViewController.m 3 | // ADPageViewDemo 4 | // 5 | // Created by ZhangCc on 2017/10/18. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #import "ADPageViewController.h" 10 | 11 | @interface ADPageViewController () 12 | 13 | @end 14 | 15 | @implementation ADPageViewController 16 | 17 | #pragma mark - Init Methods 18 | 19 | #pragma mark - Life cycle 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | 23 | self.title = @"广告页"; 24 | UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds]; 25 | webView.backgroundColor = [UIColor whiteColor]; 26 | NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.adUrl]]; 27 | [webView loadRequest:request]; 28 | [self.view addSubview:webView]; 29 | } 30 | 31 | #pragma mark - Event response 32 | 33 | #pragma mark - Notifications 34 | 35 | #pragma mark - UITableViewDelegate 36 | 37 | #pragma mark - XXXDelegate 38 | 39 | #pragma mark - Custom views 40 | 41 | #pragma mark - Setter Getter Methods 42 | 43 | #pragma mark - Public methods 44 | 45 | #pragma mark - Private methods 46 | 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /ADPageViewDemo/AppDelegate/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ADPageViewDemo 4 | // 5 | // Created by ZhangCc on 2017/10/17. 6 | // Copyright © 2017年 ZhangCc. 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 | -------------------------------------------------------------------------------- /ADPageViewDemo/AppDelegate/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ADPageViewDemo 4 | // 5 | // Created by ZhangCc on 2017/10/17. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "Manager.h" 11 | #import "ViewController.h" 12 | #import "GuidePageView.h" 13 | #import "ADPageView.h" 14 | 15 | @interface AppDelegate () 16 | 17 | @property (nonatomic, assign) BOOL isShowAdPage; 18 | 19 | @end 20 | 21 | @implementation AppDelegate 22 | 23 | 24 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 25 | 26 | self.window = [[UIWindow alloc] init]; 27 | self.window.frame = SCREEN_BOUNDS; 28 | self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]]; 29 | [self.window makeKeyAndVisible]; 30 | 31 | //启动图延迟 32 | [NSThread sleepForTimeInterval:1.f]; 33 | 34 | //首先判断是否是第一次进入或者版本更新,如果是,启动引导页;如果不是,再判断是否需要显示广告。 35 | if ([Manager isFirstLaunch]) { 36 | //启动引导页 37 | [GuidePageView sharedWithImages:@[@"1.jpg",@"2.jpg",@"3.jpg",@"4.jpg"] buttonImage:@"post_normal" buttonFrame:CGRectMake(0, -10, SCREEN_WIDTH, SCREEN_HEIGHT)]; 38 | }else { 39 | //显示广告页 40 | //后台在开发广告api的时候增加一个字段来判断是否启用广告 41 | self.isShowAdPage = YES; 42 | if (self.isShowAdPage) { 43 | [ADPageView showAdPageView]; 44 | } 45 | } 46 | return YES; 47 | } 48 | 49 | 50 | - (void)applicationWillResignActive:(UIApplication *)application { 51 | // 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. 52 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 53 | } 54 | 55 | 56 | - (void)applicationDidEnterBackground:(UIApplication *)application { 57 | // 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. 58 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 59 | } 60 | 61 | 62 | - (void)applicationWillEnterForeground:(UIApplication *)application { 63 | // 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. 64 | } 65 | 66 | 67 | - (void)applicationDidBecomeActive:(UIApplication *)application { 68 | // 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. 69 | } 70 | 71 | 72 | - (void)applicationWillTerminate:(UIApplication *)application { 73 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 74 | } 75 | 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /ADPageViewDemo/GuidePage/GuidePageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // GuidePageView.h 3 | // ADPageViewDemo 4 | // 5 | // Created by ZhangCc on 2017/10/18. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GuidePageView : UIView 12 | 13 | /** 14 | * 选中page的指示器颜色,默认白色 15 | */ 16 | @property (nonatomic, strong) UIColor *currentColor; 17 | 18 | /** 19 | * 其他状态下的指示器的颜色,默认 20 | */ 21 | @property (nonatomic, strong) UIColor *nomalColor; 22 | 23 | /** 24 | * 不带按钮的引导页,滑动到最后一页,再向右滑直接隐藏引导页 25 | * 26 | * @param imageNames 背景图片数组 27 | * 28 | * @return LaunchIntroductionView对象 29 | */ 30 | + (instancetype)sharedWithImages:(NSArray *) imageNames; 31 | 32 | /** 33 | * 带按钮的引导页 34 | * 35 | * @param imageNames 背景图片数组 36 | * @param buttonImageName 按钮的图片 37 | * @param frame 按钮的frame 38 | * 39 | * @return LaunchIntroductionView对象 40 | */ 41 | + (instancetype)sharedWithImages:(NSArray *)imageNames 42 | buttonImage:(NSString *)buttonImageName 43 | buttonFrame:(CGRect )frame; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /ADPageViewDemo/GuidePage/GuidePageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // GuidePageView.m 3 | // ADPageViewDemo 4 | // 5 | // Created by ZhangCc on 2017/10/18. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #import "GuidePageView.h" 10 | 11 | static NSString *const kAppVersion = @"appVersion"; 12 | static NSString *const kCFBundleShortVersionString = @"CFBundleShortVersionString"; 13 | 14 | 15 | @interface GuidePageView () { 16 | UIScrollView *launchScrollView; 17 | UIPageControl *page; 18 | } 19 | 20 | @end 21 | 22 | @implementation GuidePageView 23 | NSArray *images; 24 | BOOL isScrollOut;//在最后一页再次滑动是否隐藏引导页 25 | CGRect enterBtnFrame; 26 | NSString *enterBtnImage; 27 | static GuidePageView *launchView = nil; 28 | 29 | #pragma mark - Init methods 30 | //不带按钮的引导页 31 | + (instancetype)sharedWithImages:(NSArray *)imageNames { 32 | images = imageNames; 33 | isScrollOut = YES; 34 | launchView = [[GuidePageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)]; 35 | launchView.backgroundColor = [UIColor whiteColor]; 36 | return launchView; 37 | } 38 | 39 | //带按钮的引导页 40 | + (instancetype)sharedWithImages:(NSArray *)imageNames buttonImage:(NSString *)buttonImageName buttonFrame:(CGRect)frame { 41 | images = imageNames; 42 | isScrollOut = NO; 43 | enterBtnFrame = frame; 44 | enterBtnImage = buttonImageName; 45 | launchView = [[GuidePageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)]; 46 | launchView.backgroundColor = [UIColor whiteColor]; 47 | return launchView; 48 | } 49 | 50 | - (instancetype)initWithFrame:(CGRect)frame { 51 | self = [super initWithFrame:frame]; 52 | if (self) { 53 | [self addObserver:self forKeyPath:@"currentColor" options:NSKeyValueObservingOptionNew context:nil]; 54 | [self addObserver:self forKeyPath:@"nomalColor" options:NSKeyValueObservingOptionNew context:nil]; 55 | UIWindow *window = [[UIApplication sharedApplication] windows].lastObject; 56 | [window addSubview:self]; 57 | [self addImages]; 58 | } 59 | return self; 60 | } 61 | 62 | //添加引导页图片 63 | - (void)addImages { 64 | [self createScrollView]; 65 | } 66 | 67 | - (void)createScrollView { 68 | launchScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)]; 69 | launchScrollView.showsHorizontalScrollIndicator = NO; 70 | launchScrollView.bounces = NO; 71 | launchScrollView.pagingEnabled = YES; 72 | launchScrollView.delegate = self; 73 | launchScrollView.contentSize = CGSizeMake(SCREEN_WIDTH * images.count, SCREEN_HEIGHT); 74 | [self addSubview:launchScrollView]; 75 | 76 | for (int i = 0; i < images.count; i ++) { 77 | UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i * SCREEN_WIDTH, 0, SCREEN_WIDTH, SCREEN_HEIGHT)]; 78 | imageView.image = [UIImage imageNamed:images[i]]; 79 | [launchScrollView addSubview:imageView]; 80 | if (i == images.count - 1) { 81 | //判断要不要添加button 82 | if (!isScrollOut) { 83 | UIButton *enterButton = [[UIButton alloc] initWithFrame:CGRectMake(enterBtnFrame.origin.x, enterBtnFrame.origin.y, enterBtnFrame.size.width, enterBtnFrame.size.height)]; 84 | [enterButton setImage:[UIImage imageNamed:enterBtnImage] forState:UIControlStateNormal]; 85 | [enterButton addTarget:self action:@selector(enterBtnClick) forControlEvents:UIControlEventTouchUpInside]; 86 | [imageView addSubview:enterButton]; 87 | imageView.userInteractionEnabled = YES; 88 | } 89 | } 90 | } 91 | page = [[UIPageControl alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - 50, SCREEN_WIDTH, 30)]; 92 | page.numberOfPages = images.count; 93 | page.backgroundColor = [UIColor clearColor]; 94 | page.currentPage = 0; 95 | page.defersCurrentPageDisplay = YES; 96 | [self addSubview:page]; 97 | } 98 | 99 | #pragma mark - Event response 100 | //进入按钮 101 | - (void)enterBtnClick { 102 | [self hideGuidView]; 103 | } 104 | 105 | //隐藏引导页 106 | - (void)hideGuidView { 107 | [UIView animateWithDuration:0.5 animations:^{ 108 | self.alpha = 0; 109 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 110 | [self removeFromSuperview]; 111 | }); 112 | }]; 113 | } 114 | 115 | #pragma mark - ScrollView Delegate 116 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { 117 | int cuttentIndex = (int)(scrollView.contentOffset.x + SCREEN_WIDTH/2)/SCREEN_WIDTH; 118 | if (cuttentIndex == images.count - 1) { 119 | if ([self isScrolltoLeft:scrollView]) { 120 | if (!isScrollOut) { 121 | return ; 122 | } 123 | [self hideGuidView]; 124 | } 125 | } 126 | } 127 | 128 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView { 129 | if (scrollView == launchScrollView) { 130 | int cuttentIndex = (int)(scrollView.contentOffset.x + SCREEN_WIDTH/2)/SCREEN_WIDTH; 131 | page.currentPage = cuttentIndex; 132 | } 133 | } 134 | 135 | #pragma mark - Private methods 136 | //判断滚动方向 137 | - (BOOL)isScrolltoLeft:(UIScrollView *)scrollView { 138 | //YES为向左滚动,NO为右滚动 139 | if ([scrollView.panGestureRecognizer translationInView:scrollView.superview].x < 0) { 140 | return YES; 141 | }else{ 142 | return NO; 143 | } 144 | } 145 | 146 | //KVO监测值的变化 147 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 148 | if ([keyPath isEqualToString:@"currentColor"]) { 149 | page.currentPageIndicatorTintColor = self.currentColor; 150 | } 151 | if ([keyPath isEqualToString:@"nomalColor"]) { 152 | page.pageIndicatorTintColor = self.nomalColor; 153 | } 154 | } 155 | @end 156 | -------------------------------------------------------------------------------- /ADPageViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIStatusBarHidden 6 | 7 | CFBundleDevelopmentRegion 8 | $(DEVELOPMENT_LANGUAGE) 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSAppTransportSecurity 26 | 27 | NSAllowsArbitraryLoads 28 | 29 | 30 | UIRequiredDeviceCapabilities 31 | 32 | armv7 33 | 34 | UISupportedInterfaceOrientations 35 | 36 | UIInterfaceOrientationPortrait 37 | 38 | UISupportedInterfaceOrientations~ipad 39 | 40 | UIInterfaceOrientationPortrait 41 | UIInterfaceOrientationPortraitUpsideDown 42 | UIInterfaceOrientationLandscapeLeft 43 | UIInterfaceOrientationLandscapeRight 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/1.imageset/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCBrother/ADPageViewDemo/ad65e2b7cab5fb910dc4d63718179eba0cd9bbdd/ADPageViewDemo/Resours/Assets.xcassets/1.imageset/1.jpg -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "filename" : "1.jpg", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/2.imageset/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCBrother/ADPageViewDemo/ad65e2b7cab5fb910dc4d63718179eba0cd9bbdd/ADPageViewDemo/Resours/Assets.xcassets/2.imageset/3.jpg -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "filename" : "3.jpg", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/3.imageset/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCBrother/ADPageViewDemo/ad65e2b7cab5fb910dc4d63718179eba0cd9bbdd/ADPageViewDemo/Resours/Assets.xcassets/3.imageset/2.jpg -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "filename" : "2.jpg", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/4.imageset/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCBrother/ADPageViewDemo/ad65e2b7cab5fb910dc4d63718179eba0cd9bbdd/ADPageViewDemo/Resours/Assets.xcassets/4.imageset/4.jpg -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "filename" : "4.jpg", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "size" : "40x40", 25 | "idiom" : "iphone", 26 | "filename" : "cc40@2x.jpg", 27 | "scale" : "2x" 28 | }, 29 | { 30 | "size" : "40x40", 31 | "idiom" : "iphone", 32 | "filename" : "cc40@3x.jpg", 33 | "scale" : "3x" 34 | }, 35 | { 36 | "size" : "60x60", 37 | "idiom" : "iphone", 38 | "filename" : "cc60@2x.jpg", 39 | "scale" : "2x" 40 | }, 41 | { 42 | "size" : "60x60", 43 | "idiom" : "iphone", 44 | "filename" : "cc60@3x.jpg", 45 | "scale" : "3x" 46 | }, 47 | { 48 | "idiom" : "ios-marketing", 49 | "size" : "1024x1024", 50 | "scale" : "1x" 51 | } 52 | ], 53 | "info" : { 54 | "version" : 1, 55 | "author" : "xcode" 56 | } 57 | } -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/AppIcon.appiconset/cc40@2x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCBrother/ADPageViewDemo/ad65e2b7cab5fb910dc4d63718179eba0cd9bbdd/ADPageViewDemo/Resours/Assets.xcassets/AppIcon.appiconset/cc40@2x.jpg -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/AppIcon.appiconset/cc40@3x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCBrother/ADPageViewDemo/ad65e2b7cab5fb910dc4d63718179eba0cd9bbdd/ADPageViewDemo/Resours/Assets.xcassets/AppIcon.appiconset/cc40@3x.jpg -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/AppIcon.appiconset/cc60@2x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCBrother/ADPageViewDemo/ad65e2b7cab5fb910dc4d63718179eba0cd9bbdd/ADPageViewDemo/Resours/Assets.xcassets/AppIcon.appiconset/cc60@2x.jpg -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/AppIcon.appiconset/cc60@3x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCBrother/ADPageViewDemo/ad65e2b7cab5fb910dc4d63718179eba0cd9bbdd/ADPageViewDemo/Resours/Assets.xcassets/AppIcon.appiconset/cc60@3x.jpg -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "11.0", 8 | "subtype" : "2436h", 9 | "scale" : "3x" 10 | }, 11 | { 12 | "extent" : "full-screen", 13 | "idiom" : "iphone", 14 | "subtype" : "736h", 15 | "filename" : "mizhi1104@3x.png", 16 | "minimum-system-version" : "8.0", 17 | "orientation" : "portrait", 18 | "scale" : "3x" 19 | }, 20 | { 21 | "extent" : "full-screen", 22 | "idiom" : "iphone", 23 | "subtype" : "667h", 24 | "filename" : "mizhi667@2x.png", 25 | "minimum-system-version" : "8.0", 26 | "orientation" : "portrait", 27 | "scale" : "2x" 28 | } 29 | ], 30 | "info" : { 31 | "version" : 1, 32 | "author" : "xcode" 33 | } 34 | } -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/LaunchImage.launchimage/mizhi1104@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCBrother/ADPageViewDemo/ad65e2b7cab5fb910dc4d63718179eba0cd9bbdd/ADPageViewDemo/Resours/Assets.xcassets/LaunchImage.launchimage/mizhi1104@3x.png -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Assets.xcassets/LaunchImage.launchimage/mizhi667@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCBrother/ADPageViewDemo/ad65e2b7cab5fb910dc4d63718179eba0cd9bbdd/ADPageViewDemo/Resours/Assets.xcassets/LaunchImage.launchimage/mizhi667@2x.png -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/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 | 29 | 30 | -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Base.lproj/Main.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 | -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Header.h 3 | // ADPageViewDemo 4 | // 5 | // Created by ZhangCc on 2017/10/18. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #ifndef Header_h 10 | #define Header_h 11 | 12 | 13 | #endif /* Header_h */ 14 | 15 | 16 | 17 | //--------------------获取屏幕宽度与高度-------------------- 18 | #define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width 19 | #define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height 20 | #define SCREEN_BOUNDS [UIScreen mainScreen].bounds 21 | 22 | //--------------------NSUserDefaults 存/取/删对象-------------------- 23 | //存储对象 24 | #define UserDefaultSetObjectForKey(__VALUE__,__KEY__) [[NSUserDefaults standardUserDefaults] setObject:__VALUE__ forKey:__KEY__] 25 | 26 | //获得存储的对象 27 | #define UserDefaultObjectForKey(__KEY__) [[NSUserDefaults standardUserDefaults] objectForKey:__KEY__] 28 | 29 | //删除对象 30 | #define UserDefaultRemoveObjectForKey(__KEY__) \ {\ [[NSUserDefaults standardUserDefaults] removeObjectForKey:__KEY__];\ [[NSUserDefaults standardUserDefaults] synchronize];\ } 31 | 32 | //同步对象 33 | #define UserDefaultSynchronize [[NSUserDefaults standardUserDefaults] synchronize] 34 | 35 | //--------------------颜色-------------------- 36 | //设置RGB颜色 37 | #define RGBColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]//用10进制表示颜色,例如(255,255,255)黑色 38 | //设置RGBA颜色 39 | #define RGBAColor(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(r)/255.0 blue:(r)/255.0 alpha:a] 40 | //设置随机颜色 41 | #define RandomColor ZKRGBColor(arc4random_uniform(255), arc4random_uniform(255), arc4random_uniform(255)) 42 | //清空颜色 43 | #define ClearColor [UIColor clearColor] 44 | 45 | //--------------------沙盒目录文件-------------------- 46 | //获取 temp 47 | #define kPathTemp NSTemporaryDirectory() 48 | 49 | //获取沙盒 Document 50 | #define kPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] 51 | 52 | //获取沙盒 Cache 53 | #define kPathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject] 54 | -------------------------------------------------------------------------------- /ADPageViewDemo/Resours/PrefixHeader.pch: -------------------------------------------------------------------------------- 1 | // 2 | // PrefixHeader.pch 3 | // ADPageViewDemo 4 | // 5 | // Created by ZhangCc on 2017/10/18. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #ifndef PrefixHeader_pch 10 | #define PrefixHeader_pch 11 | 12 | // Include any system framework and library headers here that should be included in all compilation units. 13 | // You will also need to set the Prefix Header build setting of one or more of your targets to reference this file. 14 | 15 | #endif /* PrefixHeader_pch */ 16 | 17 | #import "Header.h" 18 | #import 19 | #import 20 | -------------------------------------------------------------------------------- /ADPageViewDemo/Utils/Manager.h: -------------------------------------------------------------------------------- 1 | // 2 | // Manager.h 3 | // ADPageViewDemo 4 | // 5 | // Created by ZhangCc on 2017/10/17. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Manager : NSObject 12 | 13 | //判断是否是首次登录或者版本更新 14 | + (BOOL)isFirstLaunch; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ADPageViewDemo/Utils/Manager.m: -------------------------------------------------------------------------------- 1 | // 2 | // Manager.m 3 | // ADPageViewDemo 4 | // 5 | // Created by ZhangCc on 2017/10/17. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #import "Manager.h" 10 | 11 | static NSString *const kAppVersion = @"appVersion"; 12 | static NSString *const kCFBundleShortVersionString = @"CFBundleShortVersionString"; 13 | 14 | @implementation Manager 15 | 16 | //判断是否是首次登录或者版本更新 17 | + (BOOL)isFirstLaunch { 18 | //获取当前版本号 19 | NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary]; 20 | NSString *currentVersion = infoDic[kCFBundleShortVersionString]; 21 | //获取上次启动应用保存的appVersion 22 | NSString *version = [[NSUserDefaults standardUserDefaults] objectForKey:kAppVersion]; 23 | //版本升级或首次登录 24 | if (version == nil || ![version isEqualToString:currentVersion]) { 25 | [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:kAppVersion]; 26 | [[NSUserDefaults standardUserDefaults] synchronize]; 27 | NSLog(@"首次登录或版本升级"); 28 | return YES; 29 | }else { 30 | NSLog(@"不是首次登录或版本升级"); 31 | return NO; 32 | } 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /ADPageViewDemo/ViewController/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ADPageViewDemo 4 | // 5 | // Created by ZhangCc on 2017/10/17. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /ADPageViewDemo/ViewController/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ADPageViewDemo 4 | // 5 | // Created by ZhangCc on 2017/10/17. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "ADPageViewController.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | self.title = @"首页"; 21 | self.view.backgroundColor = [UIColor cyanColor]; 22 | 23 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushToAd) name:@"pushToAd" object:nil]; 24 | } 25 | 26 | - (void)pushToAd { 27 | ADPageViewController *adVC = [[ADPageViewController alloc] init]; 28 | adVC.adUrl = @"https://www.baidu.com/index.php?tn=monline_3_dg"; 29 | [self.navigationController pushViewController:adVC animated:YES]; 30 | } 31 | 32 | -(void)dealloc { 33 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /ADPageViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ADPageViewDemo 4 | // 5 | // Created by ZhangCc on 2017/10/17. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #import 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 | -------------------------------------------------------------------------------- /ADPageViewDemoTests/ADPageViewDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ADPageViewDemoTests.m 3 | // ADPageViewDemoTests 4 | // 5 | // Created by ZhangCc on 2017/10/17. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ADPageViewDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ADPageViewDemoTests 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 | -------------------------------------------------------------------------------- /ADPageViewDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | -------------------------------------------------------------------------------- /ADPageViewDemoUITests/ADPageViewDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ADPageViewDemoUITests.m 3 | // ADPageViewDemoUITests 4 | // 5 | // Created by ZhangCc on 2017/10/17. 6 | // Copyright © 2017年 ZhangCc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ADPageViewDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ADPageViewDemoUITests 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 | -------------------------------------------------------------------------------- /ADPageViewDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '8.0' 2 | use_frameworks! 3 | 4 | target 'ADPageViewDemo' do 5 | 6 | pod 'SDWebImage', '~> 4.0.0' 7 | pod 'SDAutoLayout', '~> 2.2.0' 8 | 9 | end 10 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SDAutoLayout (2.2.0) 3 | - SDWebImage (4.0.0): 4 | - SDWebImage/Core (= 4.0.0) 5 | - SDWebImage/Core (4.0.0) 6 | 7 | DEPENDENCIES: 8 | - SDAutoLayout (~> 2.2.0) 9 | - SDWebImage (~> 4.0.0) 10 | 11 | SPEC CHECKSUMS: 12 | SDAutoLayout: c5509e77ae75735d9a39f7bc83dba6d3f75d49d8 13 | SDWebImage: 76a6348bdc74eb5a55dd08a091ef298e56b55e41 14 | 15 | PODFILE CHECKSUM: ce27f256b363917f05ef8f2c5626fd05f95f180a 16 | 17 | COCOAPODS: 1.4.0.beta.1 18 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SDAutoLayout (2.2.0) 3 | - SDWebImage (4.0.0): 4 | - SDWebImage/Core (= 4.0.0) 5 | - SDWebImage/Core (4.0.0) 6 | 7 | DEPENDENCIES: 8 | - SDAutoLayout (~> 2.2.0) 9 | - SDWebImage (~> 4.0.0) 10 | 11 | SPEC CHECKSUMS: 12 | SDAutoLayout: c5509e77ae75735d9a39f7bc83dba6d3f75d49d8 13 | SDWebImage: 76a6348bdc74eb5a55dd08a091ef298e56b55e41 14 | 15 | PODFILE CHECKSUM: ce27f256b363917f05ef8f2c5626fd05f95f180a 16 | 17 | COCOAPODS: 1.4.0.beta.1 18 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/ZXX.xcuserdatad/xcschemes/Pods-ADPageViewDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 47 | 48 | 54 | 55 | 56 | 57 | 58 | 59 | 65 | 66 | 68 | 69 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/ZXX.xcuserdatad/xcschemes/SDAutoLayout.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/ZXX.xcuserdatad/xcschemes/SDWebImage.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/ZXX.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Pods-ADPageViewDemo.xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | SDAutoLayout.xcscheme 15 | 16 | isShown 17 | 18 | orderHint 19 | 1 20 | 21 | SDWebImage.xcscheme 22 | 23 | isShown 24 | 25 | orderHint 26 | 2 27 | 28 | 29 | SuppressBuildableAutocreation 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Pods/SDAutoLayout/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 GSD_iOS 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Pods/SDAutoLayout/README.md: -------------------------------------------------------------------------------- 1 | # SDAutoLayout(一行代码搞定自动布局!) 2 | 3 | ##众多公司和个人开发者已经使用本库布局: 4 | SDAutoLayout使用者开发的部分app截图 http://www.jianshu.com/p/9bc04d3effb8 5 | 6 | 一行代码搞定自动布局!致力于做最简单易用的Autolayout库。The most easy way for autolayout. 7 | 8 | ## 技术支持(QQ交流群): 9 | 10 | 497140713(1群) 519489682(2群已满) 11 | 12 | ##Pod支持: 13 | 14 | 支持pod: pod 'SDAutoLayout', '~> 2.1.3' 15 | 16 | 如果发现pod search SDAutoLayout 搜索出来的不是最新版本,需要在终端执行cd转换文件路径命令退回到desktop,然后执行pod setup命令更新本地spec缓存(可能需要几分钟),然后再搜索就可以了 17 | 18 | ## 更新记录: 19 | 20 | 2017.06.26 -- 解决部分开发者反应因出现“UITableViewCellContentView”而导致应用审核被拒问题 21 | 22 | 2016.08.12 -- 实现在tableview插入新的cell数据时自动缓存管理 23 | 24 | 2016.06.30 -- 增加多参照view的leftSpaceToView和topSpaceToView约束,例:topSpaceToView(@[self.view3, self.view4], 30) 25 | 26 | 2016.06.24 -- 修复给button设置约束时在iOS8.x系统中出现的崩溃问题;发布2.1.2版本 27 | 28 | 2016.06.23 -- 实现删除某行cell时自动调整height缓存 29 | 30 | 2016.05.16 -- 修复用xib生成的view出现的部分约束失效问题(发布pod2.0.0版本) 31 | 32 | 2016.05.15 -- 增加设置偏移量offset功能 33 | 34 | 2016.04.30 -- 修复之前button作为父视图时内部控件不能自动布局问题 35 | 36 | 2016.04.05 -- 修复宽度自适应label在重用时候偶尔出现的宽度计算不准确的问题(发布pod1.51版本) 37 | 38 | 2016.03.23 -- 升级了缓存机制,新版本在tableview滑动cell时候流畅度和性能提升20%以上(发布pod1.50版本) 39 | 40 | 2016.01.23 -- 增加label对attributedString的内容自适应 41 | 42 | 2016.01.21 -- 实现tableview局部刷新cell高度缓存的自动管理 43 | 44 | 2016.01.20 -- demo适配在ios7上的屏幕旋转问题 45 | 46 | 2016.01.18 -- 推出“普通简化版”tableview的cell自动高度方法(推荐使用),原来的需2步设置的普通版方法将标记过期 47 | 48 | 2016.01.13 -- 增加在不确定bottom view的情况下的cell高度自适应方法 49 | 50 | 2016.01.07 -- 1.增加 scrollview 横向内容自适应功能;2.增加view宽高相等的功能 51 | 52 | 2016.01.03 -- 增加任何类型对象都可以实现一行代码搞定cell高度自适应;增加文档注释 53 | 54 | 2015.12.08 -- 重大升级:1.支持scrollview内容自适应;2.任意添加或者修改约束不冲突;3.性能提升40%以上;4.添加最大、最小宽高约束 55 | 56 | 57 | ## 视频教程: 58 | ☆☆ SDAutoLayout 基础版视频教程:http://www.letv.com/ptv/vplay/24038772.html ☆☆ 59 | 60 | ☆☆ SDAutoLayout 进阶版视频教程:http://www.letv.com/ptv/vplay/24381390.html ☆☆ 61 | 62 | ☆☆ SDAutoLayout 原理简介视频教程:http://www.iqiyi.com/w_19rt0tec4p.html ☆☆ 63 | 64 | ☆☆ SDAutoLayout 朋友圈demo视频教程:http://v.youku.com/v_show/id_XMTYzNzg2NzA0MA==.html ☆☆ 65 | 66 | ## 部分SDAutoLayout的DEMO: 67 | 68 | 完整微信Demo https://github.com/gsdios/GSD_WeiXin 69 | 70 | ![](http://ww3.sinaimg.cn/mw690/9b8146edgw1f1nm3pziawg205u0a0qv5.gif)![](http://ww1.sinaimg.cn/bmiddle/9b8146edgw1f06aoe2umhg206e0b4u0x.gif)![](http://ww4.sinaimg.cn/bmiddle/9b8146edgw1ezal3smihcg206y0ciqv5.gif)![](http://ww3.sinaimg.cn/mw690/9b8146edgw1f1nm3lweg3g207s0dcu0x.gif)![](http://ww2.sinaimg.cn/mw690/9b8146edgw1f23irukb0qg207i0dwu0x.gif)![](http://ww2.sinaimg.cn/bmiddle/9b8146edgw1eya1jv951ig208c0etqv5.gif) 71 | 72 | 73 | 74 | # 用法简介 75 | 76 | ## tableview和cell高度自适应: 77 | 78 | ####普通(简化)版【推荐使用】:tableview 高度自适应设置只需要2步 79 | 80 | 1. >> 设置cell高度自适应: 81 | // cell布局设置好之后调用此方法就可以实现高度自适应(注意:如果用高度自适应则不要再以cell的底边为参照去布局其子view) 82 | [cell setupAutoHeightWithBottomView:_view4 bottomMargin:10]; 83 | 84 | 2. >> 获取自动计算出的cell高度 85 | 86 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 87 | { 88 | id model = self.modelsArray[indexPath.row]; 89 | // 获取cell高度 90 | return [self.tableView cellHeightForIndexPath:indexPath model:model keyPath:@"model" cellClass:[DemoVC9Cell class] contentViewWidth:cellContentViewWith]; 91 | } 92 | 93 | 94 | ####升级版(适应于cell条数少于100的tableview):tableview 高度自适应设置只需要2步 95 | 96 | 1. >> 设置cell高度自适应: 97 | // cell布局设置好之后调用此方法就可以实现高度自适应(注意:如果用高度自适应则不要再以cell的底边为参照去布局其子view) 98 | [cell setupAutoHeightWithBottomView:_view4 bottomMargin:10]; 99 | 100 | 2. >> 获取自动计算出的cell高度 101 | 102 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 103 | { 104 | // 获取cell高度 105 | return [self cellHeightForIndexPath:indexPath cellContentViewWidth:[UIScreen mainScreen].bounds.size.width]; 106 | } 107 | 108 | 109 | ## 普通view的自动布局: 110 | 111 | #### 用法示例 112 | /* 用法一 */ 113 | _view.sd_layout 114 | .leftSpaceToView(self.view, 10) 115 | .topSpaceToView(self.view, 80) 116 | .heightIs(130) 117 | .widthRatioToView(self.view, 0.4); 118 | 119 | /* 用法二 (一行代码搞定,其实用法一也是一行代码) */ 120 | _view.sd_layout.leftSpaceToView(self.view, 10).topSpaceToView(self.view,80).heightIs(130).widthRatioToView(self.view, 0.4); 121 | 122 | 123 | >> UILabel文字自适应: 124 | // autoHeightRatio() 传0则根据文字自动计算高度(传大于0的值则根据此数值设置高度和宽度的比值) 125 | _label.sd_layout.autoHeightRatio(0); 126 | 127 | ******************************************************************************* 128 | 129 | 注意:先把需要自动布局的view加入父view然后在进行自动布局,例: 130 | 131 | UIView *view0 = [UIView new]; 132 | UIView *view1 = [UIView new]; 133 | [self.view addSubview:view0]; 134 | [self.view addSubview:view1]; 135 | 136 | view0.sd_layout 137 | .leftSpaceToView(self.view, 10) 138 | .topSpaceToView(self.view, 80) 139 | .heightIs(100) 140 | .widthRatioToView(self.view, 0.4); 141 | 142 | view1.sd_layout 143 | .leftSpaceToView(view0, 10) 144 | .topEqualToView(view0) 145 | .heightRatioToView(view0, 1) 146 | .rightSpaceToView(self.view, 10); 147 | ******************************************************************************* 148 | 149 | #### 自动布局用法简析 150 | 151 | ![](http://ww1.sinaimg.cn/mw690/9b8146edgw1ex4or5ixkjj20k60gw3zg.jpg) 152 | 153 | 154 | 1.1 > leftSpaceToView(self.view, 10) 155 | 156 | 方法名中带有“SpaceToView”的方法表示到某个参照view的间距,需要传递2个参数:(UIView)参照view 和 (CGFloat)间距数值 157 | 158 | 1.2 > widthRatioToView(self.view, 1) 159 | 160 | 方法名中带有“RatioToView”的方法表示view的宽度或者高度等属性相对于参照view的对应属性值的比例,需要传递2个参数:(UIView)参照view 和 (CGFloat)倍数 161 | 162 | 1.3 > topEqualToView(view) 163 | 164 | 方法名中带有“EqualToView”的方法表示view的某一属性等于参照view的对应的属性值,需要传递1个参数:(UIView)参照view 165 | 166 | 1.4 > widthIs(100) 167 | 168 | 方法名中带有“Is”的方法表示view的某一属性值等于参数数值,需要传递1个参数:(CGFloat)数值 169 | 170 | # PS 171 | 172 | // 如果需要用“断言”调试程序请打开此宏(位于UIView+SDAutoLayout.h) 173 | 174 | //#define SDDebugWithAssert 175 | 176 | 177 | ![](http://ww3.sinaimg.cn/bmiddle/9b8146edgw1ex4mukixr6g209g07lhdt.gif) 178 | 179 | 180 | ![](http://upload-images.jianshu.io/upload_images/1157161-07fa43e0f539ebad.jpeg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 181 | 182 | ![](http://upload-images.jianshu.io/upload_images/1157161-453a5d33d7f3d48d.jpeg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 183 | -------------------------------------------------------------------------------- /Pods/SDAutoLayout/SDAutoLayoutDemo/SDAutoLayout/SDAutoLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // SDAutoLayout.h 3 | // SDAutoLayoutDemo 4 | // 5 | // Created by gsd on 16/6/27. 6 | // Copyright © 2016年 gsd. All rights reserved. 7 | // 8 | 9 | 10 | /* 11 | 12 | SDAutoLayout 13 | 版本:2.1.7 14 | 发布:2016.08.12 15 | 16 | */ 17 | 18 | #ifndef SDAutoLayout_h 19 | #define SDAutoLayout_h 20 | 21 | #import "UIView+SDAutoLayout.h" 22 | #import "UITableView+SDAutoTableViewCellHeight.h" 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Pods/SDAutoLayout/SDAutoLayoutDemo/SDAutoLayout/UITableView+SDAutoTableViewCellHeight.h: -------------------------------------------------------------------------------- 1 | // 2 | // UITableView+SDAutoTableViewCellHeight.h 3 | // SDAutoLayout 测试 Demo 4 | // 5 | // Created by aier on 15/11/1. 6 | // Copyright © 2015年 gsd. All rights reserved. 7 | // 8 | 9 | /* 10 | 11 | ********************************************************************************* 12 | * * 13 | * 在您使用此自动布局库的过程中如果出现bug请及时以以下任意一种方式联系我们,我们会及时修复bug并 * 14 | * 帮您解决问题。 * 15 | * QQ : 2689718696(gsdios) * 16 | * Email : gsdios@126.com * 17 | * GitHub: https://github.com/gsdios * 18 | * 新浪微博:GSD_iOS * 19 | * * 20 | ********************************************************************************* 21 | 22 | */ 23 | 24 | 25 | 26 | 27 | /* 28 | PS:cell高度自适应前提>>应该调用cell的“- (void)setupAutoHeightWithBottomView:(UIView *)bottomView bottomMargin:(CGFloat)bottomMargin”方法进行cell的自动高度设置 29 | */ 30 | 31 | #import 32 | 33 | #import "UIView+SDAutoLayout.h" 34 | 35 | @class SDCellAutoHeightManager; 36 | 37 | typedef void (^AutoCellHeightDataSettingBlock)(UITableViewCell *cell); 38 | 39 | #define kSDModelCellTag 199206 40 | 41 | 42 | 43 | #pragma mark - UITableView 方法,返回自动计算出的cell高度 44 | 45 | @interface UITableView (SDAutoTableViewCellHeight) 46 | 47 | @property (nonatomic, strong) SDCellAutoHeightManager *cellAutoHeightManager; 48 | 49 | 50 | /** 51 | * 返回计算出的cell高度(普通简化版方法,同样只需一步设置即可完成)(用法:单cell详见demo5,多cell详见demo7) 52 | * model : cell的数据模型实例 53 | * keyPath : cell的数据模型属性的属性名字符串(即kvc原理中的key) 54 | * cellClass : 当前的indexPath对应的cell的class 55 | * contentViewWidth : cell的contentView的宽度 56 | */ 57 | - (CGFloat)cellHeightForIndexPath:(NSIndexPath *)indexPath model:(id)model keyPath:(NSString *)keyPath cellClass:(Class)cellClass contentViewWidth:(CGFloat)contentViewWidth; 58 | 59 | /** 60 | * 返回计算出的cell高度(普通简化版方法,同样只需一步设置即可完成)(用法:见DemoVC14) 61 | * cellClass : 当前的indexPath对应的cell的class 62 | * contentViewWidth : cell的contentView的宽度 63 | * cellDataSetting : 设置cell数据的block 64 | */ 65 | - (CGFloat)cellHeightForIndexPath:(NSIndexPath *)indexPath cellClass:(Class)cellClass cellContentViewWidth:(CGFloat)width cellDataSetting:(AutoCellHeightDataSettingBlock)cellDataSetting; 66 | 67 | /** 刷新tableView但不清空之前已经计算好的高度缓存,用于直接将新数据拼接在旧数据之后的tableView刷新 */ 68 | - (void)reloadDataWithExistedHeightCache; 69 | 70 | /** 刷新tableView同时调整已经计算好的高度缓存,用于直接将新数据插在旧数据前面的tableView的刷新 */ 71 | - (void)reloadDataWithInsertingDataAtTheBeginingOfSection:(NSInteger)section newDataCount:(NSInteger)count; 72 | 73 | /** 74 | * 刷新tableView同时调整已经计算好的高度缓存,用于直接将新数据插在旧数据前面的tableView的刷新(用于刷新多个section) 75 | * sectionNumsArray : 要刷新的所有section序号组成的数组, 例@[@(0), @(1)] 76 | * dataCountsArray : 每个section的数据条数组成的数组, 例@[@(20), @(10)] 77 | */ 78 | - (void)reloadDataWithInsertingDataAtTheBeginingOfSections:(NSArray *)sectionNumsArray newDataCounts:(NSArray *)dataCountsArray; 79 | 80 | /** 返回所有cell的高度总和 */ 81 | - (CGFloat)cellsTotalHeight; 82 | 83 | @property (nonatomic, copy) AutoCellHeightDataSettingBlock cellDataSetting; 84 | 85 | @end 86 | 87 | 88 | 89 | 90 | #pragma mark - UITableViewController 方法,返回自动计算出的cell高度 91 | 92 | @interface UITableViewController (SDTableViewControllerAutoCellHeight) 93 | 94 | /** (UITableViewController方法)升级版!一行代码(一步设置)搞定tableview的cell高度自适应,同时适用于单cell和多cell,性能比普通版稍微差一些,不建议在数据量大的tableview中使用 */ 95 | - (CGFloat)cellHeightForIndexPath:(NSIndexPath *)indexPath cellContentViewWidth:(CGFloat)width; 96 | 97 | @end 98 | 99 | 100 | 101 | #pragma mark - NSObject 方法,返回自动计算出的cell高度 102 | 103 | @interface NSObject (SDAnyObjectAutoCellHeight) 104 | 105 | /** (NSObject方法)升级版!一行代码(一步设置)搞定tableview的cell高度自适应,同时适用于单cell和多cell,性能比普通版稍微差一些,不建议在数据量大的tableview中使用 */ 106 | - (CGFloat)cellHeightForIndexPath:(NSIndexPath *)indexPath cellContentViewWidth:(CGFloat)width tableView:(UITableView *)tableView; 107 | 108 | @end 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | // ------------------------------- 以下为库内部使用无须了解 -------------------- 127 | 128 | @interface SDCellAutoHeightManager : NSObject 129 | 130 | @property (nonatomic, assign) BOOL shouldKeepHeightCacheWhenReloadingData; 131 | 132 | @property (nonatomic, assign) CGFloat contentViewWidth; 133 | 134 | @property (nonatomic, assign) Class cellClass; 135 | 136 | @property (nonatomic, assign) CGFloat cellHeight; 137 | 138 | @property (nonatomic, strong) UITableViewCell *modelCell; 139 | 140 | @property (nonatomic, strong) NSMutableDictionary *subviewFrameCacheDict; 141 | 142 | @property (nonatomic, strong, readonly) NSDictionary *heightCacheDict; 143 | 144 | @property (nonatomic, copy) AutoCellHeightDataSettingBlock cellDataSetting; 145 | 146 | - (void)clearHeightCache; 147 | 148 | - (void)clearHeightCacheOfIndexPaths:(NSArray *)indexPaths; 149 | 150 | - (void)deleteThenResetHeightCache:(NSIndexPath *)indexPathToDelete; 151 | 152 | - (void)insertNewDataAtTheBeginingOfSection:(NSInteger)section newDataCount:(NSInteger)count; 153 | 154 | - (void)insertNewDataAtIndexPaths:(NSArray *)indexPaths; 155 | 156 | - (NSNumber *)heightCacheForIndexPath:(NSIndexPath *)indexPath; 157 | 158 | - (CGFloat)cellHeightForIndexPath:(NSIndexPath *)indexPath model:(id)model keyPath:(NSString *)keyPath; 159 | 160 | - (CGFloat)cellHeightForIndexPath:(NSIndexPath *)indexPath model:(id)model keyPath:(NSString *)keyPath cellClass:(Class)cellClass; 161 | 162 | 163 | - (NSMutableArray *)subviewFrameCachesWithIndexPath:(NSIndexPath *)indexPath;; 164 | - (void)setSubviewFrameCache:(CGRect)rect WithIndexPath:(NSIndexPath *)indexPath; 165 | 166 | - (instancetype)initWithCellClass:(Class)cellClass tableView:(UITableView *)tableView; 167 | + (instancetype)managerWithCellClass:(Class)cellClass tableView:(UITableView *)tableView; 168 | @end 169 | 170 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Pods/SDWebImage/README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | 6 | [![Build Status](http://img.shields.io/travis/rs/SDWebImage/master.svg?style=flat)](https://travis-ci.org/rs/SDWebImage) 7 | [![Pod Version](http://img.shields.io/cocoapods/v/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/) 8 | [![Pod Platform](http://img.shields.io/cocoapods/p/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/) 9 | [![Pod License](http://img.shields.io/cocoapods/l/SDWebImage.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0.html) 10 | [![Dependency Status](https://www.versioneye.com/objective-c/sdwebimage/badge.svg?style=flat)](https://www.versioneye.com/objective-c/sdwebimage) 11 | [![Reference Status](https://www.versioneye.com/objective-c/sdwebimage/reference_badge.svg?style=flat)](https://www.versioneye.com/objective-c/sdwebimage/references) 12 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/rs/SDWebImage) 13 | [![codecov](https://codecov.io/gh/rs/SDWebImage/branch/master/graph/badge.svg)](https://codecov.io/gh/rs/SDWebImage) 14 | 15 | This library provides an async image downloader with cache support. For convenience, we added categories for UI elements like `UIImageView`, `UIButton`, `MKAnnotationView`. 16 | 17 | ## Features 18 | 19 | - [x] Categories for `UIImageView`, `UIButton`, `MKAnnotationView` adding web image and cache management 20 | - [x] An asynchronous image downloader 21 | - [x] An asynchronous memory + disk image caching with automatic cache expiration handling 22 | - [x] A background image decompression 23 | - [x] A guarantee that the same URL won't be downloaded several times 24 | - [x] A guarantee that bogus URLs won't be retried again and again 25 | - [x] A guarantee that main thread will never be blocked 26 | - [x] Performances! 27 | - [x] Use GCD and ARC 28 | 29 | ## Supported Image Formats 30 | 31 | - Image formats supported by UIImage (JPEG, PNG, ...), including GIF 32 | - WebP format, including animated WebP (use the `WebP` subspec) 33 | 34 | ## Requirements 35 | 36 | - iOS 7.0 or later 37 | - tvOS 9.0 or later 38 | - watchOS 2.0 or later 39 | - OS X 10.8 or later 40 | - Xcode 7.3 or later 41 | 42 | #### Backwards compatibility 43 | 44 | - For iOS 5 and 6, use [any 3.x version up to 3.7.6](https://github.com/rs/SDWebImage/tree/3.7.6) 45 | - For iOS < 5.0, please use the last [2.0 version](https://github.com/rs/SDWebImage/tree/2.0-compat). 46 | 47 | ## Getting Started 48 | 49 | - Read this Readme doc 50 | - Read the [How to use section](https://github.com/rs/SDWebImage#how-to-use) 51 | - Read the [documentation @ CocoaDocs](http://cocoadocs.org/docsets/SDWebImage/) 52 | - Read [How is SDWebImage better than X?](https://github.com/rs/SDWebImage/wiki/How-is-SDWebImage-better-than-X%3F) 53 | - Try the example by downloading the project from Github or even easier using CocoaPods try `pod try SDWebImage` 54 | - Get to the [installation steps](https://github.com/rs/SDWebImage#installation) 55 | - Read the [SDWebImage 4.0 Migration Guide](Docs/SDWebImage-4.0-Migration-guide.md) to get an idea of the changes from 3.x to 4.x 56 | 57 | ## Who Uses It 58 | - Find out [who uses SDWebImage](https://github.com/rs/SDWebImage/wiki/Who-Uses-SDWebImage) and add your app to the list. 59 | 60 | ## Communication 61 | 62 | - If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/sdwebimage). (Tag 'sdwebimage') 63 | - If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/sdwebimage). 64 | - If you **found a bug**, open an issue. 65 | - If you **have a feature request**, open an issue. 66 | - If you **want to contribute**, submit a pull request. 67 | 68 | ## Installation 69 | 70 | ## How To Use 71 | 72 | ```objective-c 73 | Objective-C: 74 | 75 | #import 76 | ... 77 | [imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] 78 | placeholderImage:[UIImage imageNamed:@"placeholder.png"]]; 79 | ``` 80 | 81 | ```swift 82 | Swift: 83 | 84 | @import SDWebImage 85 | 86 | imageView.sd_setImage(with: URL(string: "http://www.domain.com/path/to/image.jpg"), placeholderImage: UIImage(named: "placeholder.png")) 87 | ``` 88 | 89 | - For details about how to use the library and clear examples, see [The detailed How to use](Docs/HowToUse.md) 90 | 91 | ## Animated Images (GIF) support 92 | 93 | - Starting with the 4.0 version, we rely on [FLAnimatedImage](https://github.com/Flipboard/FLAnimatedImage) to take care of our animated images. 94 | - To use it, simply make sure you use `FLAnimatedImageView` instead of `UIImageView`. 95 | - **Note**: there is a backwards compatible feature, so if you are still trying to load a GIF into a `UIImageView`, it will only show the 1st frame as a static image. 96 | - **Important**: FLAnimatedImage only works on the iOS platform, so for all the other platforms (OS X, tvOS, watchOS) we will fallback to the backwards compatibility feature described above 97 | 98 | Common Problems 99 | --------------- 100 | 101 | ### Using dynamic image size with UITableViewCell 102 | 103 | UITableView determines the size of the image by the first image set for a cell. If your remote images 104 | don't have the same size as your placeholder image, you may experience strange anamorphic scaling issue. 105 | The following article gives a way to workaround this issue: 106 | 107 | [http://www.wrichards.com/blog/2011/11/sdwebimage-fixed-width-cell-images/](http://www.wrichards.com/blog/2011/11/sdwebimage-fixed-width-cell-images/) 108 | 109 | 110 | ### Handle image refresh 111 | 112 | SDWebImage does very aggressive caching by default. It ignores all kind of caching control header returned by the HTTP server and cache the returned images with no time restriction. It implies your images URLs are static URLs pointing to images that never change. If the pointed image happen to change, some parts of the URL should change accordingly. 113 | 114 | If you don't control the image server you're using, you may not be able to change the URL when its content is updated. This is the case for Facebook avatar URLs for instance. In such case, you may use the `SDWebImageRefreshCached` flag. This will slightly degrade the performance but will respect the HTTP caching control headers: 115 | 116 | ``` objective-c 117 | [imageView sd_setImageWithURL:[NSURL URLWithString:@"https://graph.facebook.com/olivier.poitrey/picture"] 118 | placeholderImage:[UIImage imageNamed:@"avatar-placeholder.png"] 119 | options:SDWebImageRefreshCached]; 120 | ``` 121 | 122 | ### Add a progress indicator 123 | 124 | Add these before you call ```sd_setImageWithURL``` 125 | 126 | ``` objective-c 127 | [imageView setShowActivityIndicatorView:YES]; 128 | [imageView setIndicatorStyle:UIActivityIndicatorViewStyleGray]; 129 | ``` 130 | 131 | ``` swift 132 | imageView.setShowActivityIndicatorView(true) 133 | imageView.setIndicatorStyle(.Gray) 134 | ``` 135 | 136 | Installation 137 | ------------ 138 | 139 | There are three ways to use SDWebImage in your project: 140 | - using CocoaPods 141 | - using Carthage 142 | - by cloning the project into your repository 143 | 144 | ### Installation with CocoaPods 145 | 146 | [CocoaPods](http://cocoapods.org/) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the [Get Started](http://cocoapods.org/#get_started) section for more details. 147 | 148 | #### Podfile 149 | ``` 150 | platform :ios, '7.0' 151 | pod 'SDWebImage', '~>3.8' 152 | ``` 153 | 154 | If you are using Swift, be sure to add `use_frameworks!` and set your target to iOS 8+: 155 | ``` 156 | platform :ios, '8.0' 157 | use_frameworks! 158 | ``` 159 | 160 | #### Subspecs 161 | 162 | There are 3 subspecs available now: `Core`, `MapKit` and `WebP` (this means you can install only some of the SDWebImage modules. By default, you get just `Core`, so if you need `WebP`, you need to specify it). 163 | 164 | Podfile example: 165 | ``` 166 | pod 'SDWebImage/WebP' 167 | ``` 168 | 169 | ### Installation with Carthage (iOS 8+) 170 | 171 | [Carthage](https://github.com/Carthage/Carthage) is a lightweight dependency manager for Swift and Objective-C. It leverages CocoaTouch modules and is less invasive than CocoaPods. 172 | 173 | To install with carthage, follow the instruction on [Carthage](https://github.com/Carthage/Carthage) 174 | 175 | #### Cartfile 176 | ``` 177 | github "rs/SDWebImage" 178 | ``` 179 | 180 | ### Installation by cloning the repository 181 | - see [Manual install](Docs/ManualInstallation.md) 182 | 183 | ### Import headers in your source files 184 | 185 | In the source files where you need to use the library, import the header file: 186 | 187 | ```objective-c 188 | #import 189 | ``` 190 | 191 | ### Build Project 192 | 193 | At this point your workspace should build without error. If you are having problem, post to the Issue and the 194 | community can help you solve it. 195 | 196 | ## Author 197 | - [Olivier Poitrey](https://github.com/rs) 198 | 199 | ## Collaborators 200 | - [Konstantinos K.](https://github.com/mythodeia) 201 | - [Bogdan Poplauschi](https://github.com/bpoplauschi) 202 | 203 | ## Licenses 204 | 205 | All source code is licensed under the [MIT License](https://raw.github.com/rs/SDWebImage/master/LICENSE). 206 | 207 | ## Architecture 208 | 209 |

210 | 211 |

212 | 213 |

214 | 215 |

216 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Fabrice Aneche 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 | #import "SDWebImageCompat.h" 12 | 13 | typedef NS_ENUM(NSInteger, SDImageFormat) { 14 | SDImageFormatUndefined = -1, 15 | SDImageFormatJPEG = 0, 16 | SDImageFormatPNG, 17 | SDImageFormatGIF, 18 | SDImageFormatTIFF, 19 | SDImageFormatWebP 20 | }; 21 | 22 | @interface NSData (ImageContentType) 23 | 24 | /** 25 | * Return image format 26 | * 27 | * @param data the input image data 28 | * 29 | * @return the image format as `SDImageFormat` (enum) 30 | */ 31 | + (SDImageFormat)sd_imageFormatForImageData:(nullable NSData *)data; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Fabrice Aneche 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 "NSData+ImageContentType.h" 11 | 12 | 13 | @implementation NSData (ImageContentType) 14 | 15 | + (SDImageFormat)sd_imageFormatForImageData:(nullable NSData *)data { 16 | if (!data) { 17 | return SDImageFormatUndefined; 18 | } 19 | 20 | uint8_t c; 21 | [data getBytes:&c length:1]; 22 | switch (c) { 23 | case 0xFF: 24 | return SDImageFormatJPEG; 25 | case 0x89: 26 | return SDImageFormatPNG; 27 | case 0x47: 28 | return SDImageFormatGIF; 29 | case 0x49: 30 | case 0x4D: 31 | return SDImageFormatTIFF; 32 | case 0x52: 33 | // R as RIFF for WEBP 34 | if (data.length < 12) { 35 | return SDImageFormatUndefined; 36 | } 37 | 38 | NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding]; 39 | if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) { 40 | return SDImageFormatWebP; 41 | } 42 | } 43 | return SDImageFormatUndefined; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/NSImage+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 | 11 | #if SD_MAC 12 | 13 | #import 14 | 15 | @interface NSImage (WebCache) 16 | 17 | - (CGImageRef)CGImage; 18 | - (NSArray *)images; 19 | - (BOOL)isGIF; 20 | 21 | @end 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/NSImage+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 "NSImage+WebCache.h" 10 | 11 | #if SD_MAC 12 | 13 | @implementation NSImage (WebCache) 14 | 15 | - (CGImageRef)CGImage { 16 | NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height); 17 | CGImageRef cgImage = [self CGImageForProposedRect:&imageRect context:NULL hints:nil]; 18 | return cgImage; 19 | } 20 | 21 | - (NSArray *)images { 22 | return nil; 23 | } 24 | 25 | - (BOOL)isGIF { 26 | return NO; 27 | } 28 | 29 | @end 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /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 | @class SDImageCacheConfig; 13 | 14 | typedef NS_ENUM(NSInteger, SDImageCacheType) { 15 | /** 16 | * The image wasn't available the SDWebImage caches, but was downloaded from the web. 17 | */ 18 | SDImageCacheTypeNone, 19 | /** 20 | * The image was obtained from the disk cache. 21 | */ 22 | SDImageCacheTypeDisk, 23 | /** 24 | * The image was obtained from the memory cache. 25 | */ 26 | SDImageCacheTypeMemory 27 | }; 28 | 29 | typedef void(^SDCacheQueryCompletedBlock)(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType); 30 | 31 | typedef void(^SDWebImageCheckCacheCompletionBlock)(BOOL isInCache); 32 | 33 | typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger totalSize); 34 | 35 | 36 | /** 37 | * SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed 38 | * asynchronous so it doesn’t add unnecessary latency to the UI. 39 | */ 40 | @interface SDImageCache : NSObject 41 | 42 | #pragma mark - Properties 43 | 44 | /** 45 | * Cache Config object - storing all kind of settings 46 | */ 47 | @property (nonatomic, nonnull, readonly) SDImageCacheConfig *config; 48 | 49 | /** 50 | * The maximum "total cost" of the in-memory image cache. The cost function is the number of pixels held in memory. 51 | */ 52 | @property (assign, nonatomic) NSUInteger maxMemoryCost; 53 | 54 | /** 55 | * The maximum number of objects the cache should hold. 56 | */ 57 | @property (assign, nonatomic) NSUInteger maxMemoryCountLimit; 58 | 59 | #pragma mark - Singleton and initialization 60 | 61 | /** 62 | * Returns global shared cache instance 63 | * 64 | * @return SDImageCache global instance 65 | */ 66 | + (nonnull instancetype)sharedImageCache; 67 | 68 | /** 69 | * Init a new cache store with a specific namespace 70 | * 71 | * @param ns The namespace to use for this cache store 72 | */ 73 | - (nonnull instancetype)initWithNamespace:(nonnull NSString *)ns; 74 | 75 | /** 76 | * Init a new cache store with a specific namespace and directory 77 | * 78 | * @param ns The namespace to use for this cache store 79 | * @param directory Directory to cache disk images in 80 | */ 81 | - (nonnull instancetype)initWithNamespace:(nonnull NSString *)ns 82 | diskCacheDirectory:(nonnull NSString *)directory NS_DESIGNATED_INITIALIZER; 83 | 84 | #pragma mark - Cache paths 85 | 86 | - (nullable NSString *)makeDiskCachePath:(nonnull NSString*)fullNamespace; 87 | 88 | /** 89 | * Add a read-only cache path to search for images pre-cached by SDImageCache 90 | * Useful if you want to bundle pre-loaded images with your app 91 | * 92 | * @param path The path to use for this read-only cache path 93 | */ 94 | - (void)addReadOnlyCachePath:(nonnull NSString *)path; 95 | 96 | #pragma mark - Store Ops 97 | 98 | /** 99 | * Asynchronously store an image into memory and disk cache at the given key. 100 | * 101 | * @param image The image to store 102 | * @param key The unique image cache key, usually it's image absolute URL 103 | * @param completionBlock A block executed after the operation is finished 104 | */ 105 | - (void)storeImage:(nullable UIImage *)image 106 | forKey:(nullable NSString *)key 107 | completion:(nullable SDWebImageNoParamsBlock)completionBlock; 108 | 109 | /** 110 | * Asynchronously store an image into memory and disk cache at the given key. 111 | * 112 | * @param image The image to store 113 | * @param key The unique image cache key, usually it's image absolute URL 114 | * @param toDisk Store the image to disk cache if YES 115 | * @param completionBlock A block executed after the operation is finished 116 | */ 117 | - (void)storeImage:(nullable UIImage *)image 118 | forKey:(nullable NSString *)key 119 | toDisk:(BOOL)toDisk 120 | completion:(nullable SDWebImageNoParamsBlock)completionBlock; 121 | 122 | /** 123 | * Asynchronously store an image into memory and disk cache at the given key. 124 | * 125 | * @param image The image to store 126 | * @param imageData The image data as returned by the server, this representation will be used for disk storage 127 | * instead of converting the given image object into a storable/compressed image format in order 128 | * to save quality and CPU 129 | * @param key The unique image cache key, usually it's image absolute URL 130 | * @param toDisk Store the image to disk cache if YES 131 | * @param completionBlock A block executed after the operation is finished 132 | */ 133 | - (void)storeImage:(nullable UIImage *)image 134 | imageData:(nullable NSData *)imageData 135 | forKey:(nullable NSString *)key 136 | toDisk:(BOOL)toDisk 137 | completion:(nullable SDWebImageNoParamsBlock)completionBlock; 138 | 139 | /** 140 | * Synchronously store image NSData into disk cache at the given key. 141 | * 142 | * @warning This method is synchronous, make sure to call it from the ioQueue 143 | * 144 | * @param imageData The image data to store 145 | * @param key The unique image cache key, usually it's image absolute URL 146 | */ 147 | - (void)storeImageDataToDisk:(nullable NSData *)imageData forKey:(nullable NSString *)key; 148 | 149 | #pragma mark - Query and Retrieve Ops 150 | 151 | /** 152 | * Async check if image exists in disk cache already (does not load the image) 153 | * 154 | * @param key the key describing the url 155 | * @param completionBlock the block to be executed when the check is done. 156 | * @note the completion block will be always executed on the main queue 157 | */ 158 | - (void)diskImageExistsWithKey:(nullable NSString *)key completion:(nullable SDWebImageCheckCacheCompletionBlock)completionBlock; 159 | 160 | /** 161 | * Operation that queries the cache asynchronously and call the completion when done. 162 | * 163 | * @param key The unique key used to store the wanted image 164 | * @param doneBlock The completion block. Will not get called if the operation is cancelled 165 | * 166 | * @return a NSOperation instance containing the cache op 167 | */ 168 | - (nullable NSOperation *)queryCacheOperationForKey:(nullable NSString *)key done:(nullable SDCacheQueryCompletedBlock)doneBlock; 169 | 170 | /** 171 | * Query the memory cache synchronously. 172 | * 173 | * @param key The unique key used to store the image 174 | */ 175 | - (nullable UIImage *)imageFromMemoryCacheForKey:(nullable NSString *)key; 176 | 177 | /** 178 | * Query the disk cache synchronously. 179 | * 180 | * @param key The unique key used to store the image 181 | */ 182 | - (nullable UIImage *)imageFromDiskCacheForKey:(nullable NSString *)key; 183 | 184 | /** 185 | * Query the cache (memory and or disk) synchronously after checking the memory cache. 186 | * 187 | * @param key The unique key used to store the image 188 | */ 189 | - (nullable UIImage *)imageFromCacheForKey:(nullable NSString *)key; 190 | 191 | #pragma mark - Remove Ops 192 | 193 | /** 194 | * Remove the image from memory and disk cache asynchronously 195 | * 196 | * @param key The unique image cache key 197 | * @param completion A block that should be executed after the image has been removed (optional) 198 | */ 199 | - (void)removeImageForKey:(nullable NSString *)key withCompletion:(nullable SDWebImageNoParamsBlock)completion; 200 | 201 | /** 202 | * Remove the image from memory and optionally disk cache asynchronously 203 | * 204 | * @param key The unique image cache key 205 | * @param fromDisk Also remove cache entry from disk if YES 206 | * @param completion A block that should be executed after the image has been removed (optional) 207 | */ 208 | - (void)removeImageForKey:(nullable NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(nullable SDWebImageNoParamsBlock)completion; 209 | 210 | #pragma mark - Cache clean Ops 211 | 212 | /** 213 | * Clear all memory cached images 214 | */ 215 | - (void)clearMemory; 216 | 217 | /** 218 | * Async clear all disk cached images. Non-blocking method - returns immediately. 219 | * @param completion A block that should be executed after cache expiration completes (optional) 220 | */ 221 | - (void)clearDiskOnCompletion:(nullable SDWebImageNoParamsBlock)completion; 222 | 223 | /** 224 | * Async remove all expired cached image from disk. Non-blocking method - returns immediately. 225 | * @param completionBlock A block that should be executed after cache expiration completes (optional) 226 | */ 227 | - (void)deleteOldFilesWithCompletionBlock:(nullable SDWebImageNoParamsBlock)completionBlock; 228 | 229 | #pragma mark - Cache Info 230 | 231 | /** 232 | * Get the size used by the disk cache 233 | */ 234 | - (NSUInteger)getSize; 235 | 236 | /** 237 | * Get the number of images in the disk cache 238 | */ 239 | - (NSUInteger)getDiskCount; 240 | 241 | /** 242 | * Asynchronously calculate the disk cache's size. 243 | */ 244 | - (void)calculateSizeWithCompletionBlock:(nullable SDWebImageCalculateSizeBlock)completionBlock; 245 | 246 | #pragma mark - Cache Paths 247 | 248 | /** 249 | * Get the cache path for a certain key (needs the cache path root folder) 250 | * 251 | * @param key the key (can be obtained from url using cacheKeyForURL) 252 | * @param path the cache path root folder 253 | * 254 | * @return the cache path 255 | */ 256 | - (nullable NSString *)cachePathForKey:(nullable NSString *)key inPath:(nonnull NSString *)path; 257 | 258 | /** 259 | * Get the default cache path for a certain key 260 | * 261 | * @param key the key (can be obtained from url using cacheKeyForURL) 262 | * 263 | * @return the default cache path 264 | */ 265 | - (nullable NSString *)defaultCachePathForKey:(nullable NSString *)key; 266 | 267 | @end 268 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/SDImageCacheConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // SDImageCacheConfig.h 3 | // SDWebImage 4 | // 5 | // Created by Bogdan on 09/09/16. 6 | // Copyright © 2016 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | 12 | @interface SDImageCacheConfig : NSObject 13 | 14 | /** 15 | * Decompressing images that are downloaded and cached can improve performance but can consume lot of memory. 16 | * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption. 17 | */ 18 | @property (assign, nonatomic) BOOL shouldDecompressImages; 19 | 20 | /** 21 | * disable iCloud backup [defaults to YES] 22 | */ 23 | @property (assign, nonatomic) BOOL shouldDisableiCloud; 24 | 25 | /** 26 | * use memory cache [defaults to YES] 27 | */ 28 | @property (assign, nonatomic) BOOL shouldCacheImagesInMemory; 29 | 30 | /** 31 | * The maximum length of time to keep an image in the cache, in seconds 32 | */ 33 | @property (assign, nonatomic) NSInteger maxCacheAge; 34 | 35 | /** 36 | * The maximum size of the cache, in bytes. 37 | */ 38 | @property (assign, nonatomic) NSUInteger maxCacheSize; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/SDImageCacheConfig.m: -------------------------------------------------------------------------------- 1 | // 2 | // SDImageCacheConfig.m 3 | // SDWebImage 4 | // 5 | // Created by Bogdan on 09/09/16. 6 | // Copyright © 2016 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import "SDImageCacheConfig.h" 10 | 11 | static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week 12 | 13 | @implementation SDImageCacheConfig 14 | 15 | - (instancetype)init { 16 | if (self = [super init]) { 17 | _shouldDecompressImages = YES; 18 | _shouldDisableiCloud = YES; 19 | _shouldCacheImagesInMemory = YES; 20 | _maxCacheAge = kDefaultCacheMaxCacheAge; 21 | _maxCacheSize = 0; 22 | } 23 | return self; 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /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 | // Apple's defines from TargetConditionals.h are a bit weird. 17 | // Seems like TARGET_OS_MAC is always defined (on all platforms). 18 | // To determine if we are running on OSX, we can only relly on TARGET_OS_IPHONE=0 and all the other platforms 19 | #if !TARGET_OS_IPHONE && !TARGET_OS_IOS && !TARGET_OS_TV && !TARGET_OS_WATCH 20 | #define SD_MAC 1 21 | #else 22 | #define SD_MAC 0 23 | #endif 24 | 25 | // iOS and tvOS are very similar, UIKit exists on both platforms 26 | // Note: watchOS also has UIKit, but it's very limited 27 | #if TARGET_OS_IOS || TARGET_OS_TV 28 | #define SD_UIKIT 1 29 | #else 30 | #define SD_UIKIT 0 31 | #endif 32 | 33 | #if TARGET_OS_IOS 34 | #define SD_IOS 1 35 | #else 36 | #define SD_IOS 0 37 | #endif 38 | 39 | #if TARGET_OS_TV 40 | #define SD_TV 1 41 | #else 42 | #define SD_TV 0 43 | #endif 44 | 45 | #if TARGET_OS_WATCH 46 | #define SD_WATCH 1 47 | #else 48 | #define SD_WATCH 0 49 | #endif 50 | 51 | 52 | #if SD_MAC 53 | #import 54 | #ifndef UIImage 55 | #define UIImage NSImage 56 | #endif 57 | #ifndef UIImageView 58 | #define UIImageView NSImageView 59 | #endif 60 | #ifndef UIView 61 | #define UIView NSView 62 | #endif 63 | #else 64 | #if __IPHONE_OS_VERSION_MIN_REQUIRED != 20000 && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 65 | #error SDWebImage doesn't support Deployment Target version < 5.0 66 | #endif 67 | 68 | #if SD_UIKIT 69 | #import 70 | #endif 71 | #if SD_WATCH 72 | #import 73 | #endif 74 | #endif 75 | 76 | #ifndef NS_ENUM 77 | #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type 78 | #endif 79 | 80 | #ifndef NS_OPTIONS 81 | #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type 82 | #endif 83 | 84 | #if OS_OBJECT_USE_OBJC 85 | #undef SDDispatchQueueRelease 86 | #undef SDDispatchQueueSetterSementics 87 | #define SDDispatchQueueRelease(q) 88 | #define SDDispatchQueueSetterSementics strong 89 | #else 90 | #undef SDDispatchQueueRelease 91 | #undef SDDispatchQueueSetterSementics 92 | #define SDDispatchQueueRelease(q) (dispatch_release(q)) 93 | #define SDDispatchQueueSetterSementics assign 94 | #endif 95 | 96 | extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image); 97 | 98 | typedef void(^SDWebImageNoParamsBlock)(); 99 | 100 | extern NSString *const SDWebImageErrorDomain; 101 | 102 | #ifndef dispatch_main_async_safe 103 | #define dispatch_main_async_safe(block)\ 104 | if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(dispatch_get_main_queue())) == 0) {\ 105 | block();\ 106 | } else {\ 107 | dispatch_async(dispatch_get_main_queue(), block);\ 108 | } 109 | #endif 110 | 111 | static int64_t kAsyncTestTimeout = 5; 112 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/SDWebImageCompat.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 "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 * _Nullable key, UIImage * _Nullable image) { 16 | if (!image) { 17 | return nil; 18 | } 19 | 20 | #if SD_MAC 21 | return image; 22 | #elif SD_UIKIT || SD_WATCH 23 | if ((image.images).count > 0) { 24 | NSMutableArray *scaledImages = [NSMutableArray array]; 25 | 26 | for (UIImage *tempImage in image.images) { 27 | [scaledImages addObject:SDScaledImageForKey(key, tempImage)]; 28 | } 29 | 30 | return [UIImage animatedImageWithImages:scaledImages duration:image.duration]; 31 | } 32 | else { 33 | #if SD_WATCH 34 | if ([[WKInterfaceDevice currentDevice] respondsToSelector:@selector(screenScale)]) { 35 | #elif SD_UIKIT 36 | if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { 37 | #endif 38 | CGFloat scale = 1; 39 | if (key.length >= 8) { 40 | NSRange range = [key rangeOfString:@"@2x."]; 41 | if (range.location != NSNotFound) { 42 | scale = 2.0; 43 | } 44 | 45 | range = [key rangeOfString:@"@3x."]; 46 | if (range.location != NSNotFound) { 47 | scale = 3.0; 48 | } 49 | } 50 | 51 | UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; 52 | image = scaledImage; 53 | } 54 | return image; 55 | } 56 | #endif 57 | } 58 | 59 | NSString *const SDWebImageErrorDomain = @"SDWebImageErrorDomain"; 60 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/SDWebImageDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) james 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 | #import "SDWebImageCompat.h" 12 | 13 | @interface UIImage (ForceDecode) 14 | 15 | + (nullable UIImage *)decodedImageWithImage:(nullable UIImage *)image; 16 | 17 | + (nullable UIImage *)decodedAndScaledDownImageWithImage:(nullable UIImage *)image; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /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 | * Scale down the image 55 | */ 56 | SDWebImageDownloaderScaleDownLargeImages = 1 << 8, 57 | }; 58 | 59 | typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) { 60 | /** 61 | * Default value. All download operations will execute in queue style (first-in-first-out). 62 | */ 63 | SDWebImageDownloaderFIFOExecutionOrder, 64 | 65 | /** 66 | * All download operations will execute in stack style (last-in-first-out). 67 | */ 68 | SDWebImageDownloaderLIFOExecutionOrder 69 | }; 70 | 71 | extern NSString * _Nonnull const SDWebImageDownloadStartNotification; 72 | extern NSString * _Nonnull const SDWebImageDownloadStopNotification; 73 | 74 | typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL); 75 | 76 | typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished); 77 | 78 | typedef NSDictionary SDHTTPHeadersDictionary; 79 | typedef NSMutableDictionary SDHTTPHeadersMutableDictionary; 80 | 81 | typedef SDHTTPHeadersDictionary * _Nullable (^SDWebImageDownloaderHeadersFilterBlock)(NSURL * _Nullable url, SDHTTPHeadersDictionary * _Nullable headers); 82 | 83 | /** 84 | * A token associated with each download. Can be used to cancel a download 85 | */ 86 | @interface SDWebImageDownloadToken : NSObject 87 | 88 | @property (nonatomic, strong, nullable) NSURL *url; 89 | @property (nonatomic, strong, nullable) id downloadOperationCancelToken; 90 | 91 | @end 92 | 93 | 94 | /** 95 | * Asynchronous downloader dedicated and optimized for image loading. 96 | */ 97 | @interface SDWebImageDownloader : NSObject 98 | 99 | /** 100 | * Decompressing images that are downloaded and cached can improve performance but can consume lot of memory. 101 | * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption. 102 | */ 103 | @property (assign, nonatomic) BOOL shouldDecompressImages; 104 | 105 | /** 106 | * The maximum number of concurrent downloads 107 | */ 108 | @property (assign, nonatomic) NSInteger maxConcurrentDownloads; 109 | 110 | /** 111 | * Shows the current amount of downloads that still need to be downloaded 112 | */ 113 | @property (readonly, nonatomic) NSUInteger currentDownloadCount; 114 | 115 | 116 | /** 117 | * The timeout value (in seconds) for the download operation. Default: 15.0. 118 | */ 119 | @property (assign, nonatomic) NSTimeInterval downloadTimeout; 120 | 121 | 122 | /** 123 | * Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`. 124 | */ 125 | @property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder; 126 | 127 | /** 128 | * Singleton method, returns the shared instance 129 | * 130 | * @return global shared instance of downloader class 131 | */ 132 | + (nonnull instancetype)sharedDownloader; 133 | 134 | /** 135 | * Set the default URL credential to be set for request operations. 136 | */ 137 | @property (strong, nonatomic, nullable) NSURLCredential *urlCredential; 138 | 139 | /** 140 | * Set username 141 | */ 142 | @property (strong, nonatomic, nullable) NSString *username; 143 | 144 | /** 145 | * Set password 146 | */ 147 | @property (strong, nonatomic, nullable) NSString *password; 148 | 149 | /** 150 | * Set filter to pick headers for downloading image HTTP request. 151 | * 152 | * This block will be invoked for each downloading image request, returned 153 | * NSDictionary will be used as headers in corresponding HTTP request. 154 | */ 155 | @property (nonatomic, copy, nullable) SDWebImageDownloaderHeadersFilterBlock headersFilter; 156 | 157 | /** 158 | * Creates an instance of a downloader with specified session configuration. 159 | * *Note*: `timeoutIntervalForRequest` is going to be overwritten. 160 | * @return new instance of downloader class 161 | */ 162 | - (nonnull instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)sessionConfiguration NS_DESIGNATED_INITIALIZER; 163 | 164 | /** 165 | * Set a value for a HTTP header to be appended to each download HTTP request. 166 | * 167 | * @param value The value for the header field. Use `nil` value to remove the header. 168 | * @param field The name of the header field to set. 169 | */ 170 | - (void)setValue:(nullable NSString *)value forHTTPHeaderField:(nullable NSString *)field; 171 | 172 | /** 173 | * Returns the value of the specified HTTP header field. 174 | * 175 | * @return The value associated with the header field field, or `nil` if there is no corresponding header field. 176 | */ 177 | - (nullable NSString *)valueForHTTPHeaderField:(nullable NSString *)field; 178 | 179 | /** 180 | * Sets a subclass of `SDWebImageDownloaderOperation` as the default 181 | * `NSOperation` to be used each time SDWebImage constructs a request 182 | * operation to download an image. 183 | * 184 | * @param operationClass The subclass of `SDWebImageDownloaderOperation` to set 185 | * as default. Passing `nil` will revert to `SDWebImageDownloaderOperation`. 186 | */ 187 | - (void)setOperationClass:(nullable Class)operationClass; 188 | 189 | /** 190 | * Creates a SDWebImageDownloader async downloader instance with a given URL 191 | * 192 | * The delegate will be informed when the image is finish downloaded or an error has happen. 193 | * 194 | * @see SDWebImageDownloaderDelegate 195 | * 196 | * @param url The URL to the image to download 197 | * @param options The options to be used for this download 198 | * @param progressBlock A block called repeatedly while the image is downloading 199 | * @note the progress block is executed on a background queue 200 | * @param completedBlock A block called once the download is completed. 201 | * If the download succeeded, the image parameter is set, in case of error, 202 | * error parameter is set with the error. The last parameter is always YES 203 | * if SDWebImageDownloaderProgressiveDownload isn't use. With the 204 | * SDWebImageDownloaderProgressiveDownload option, this block is called 205 | * repeatedly with the partial image object and the finished argument set to NO 206 | * before to be called a last time with the full image and finished argument 207 | * set to YES. In case of error, the finished argument is always YES. 208 | * 209 | * @return A token (SDWebImageDownloadToken) that can be passed to -cancel: to cancel this operation 210 | */ 211 | - (nullable SDWebImageDownloadToken *)downloadImageWithURL:(nullable NSURL *)url 212 | options:(SDWebImageDownloaderOptions)options 213 | progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock 214 | completed:(nullable SDWebImageDownloaderCompletedBlock)completedBlock; 215 | 216 | /** 217 | * Cancels a download that was previously queued using -downloadImageWithURL:options:progress:completed: 218 | * 219 | * @param token The token received from -downloadImageWithURL:options:progress:completed: that should be canceled. 220 | */ 221 | - (void)cancel:(nullable SDWebImageDownloadToken *)token; 222 | 223 | /** 224 | * Sets the download queue suspension state 225 | */ 226 | - (void)setSuspended:(BOOL)suspended; 227 | 228 | /** 229 | * Cancels all download operations in the queue 230 | */ 231 | - (void)cancelAllDownloads; 232 | 233 | @end 234 | -------------------------------------------------------------------------------- /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 * _Nonnull const SDWebImageDownloadStartNotification; 14 | extern NSString * _Nonnull const SDWebImageDownloadReceiveResponseNotification; 15 | extern NSString * _Nonnull const SDWebImageDownloadStopNotification; 16 | extern NSString * _Nonnull const SDWebImageDownloadFinishNotification; 17 | 18 | 19 | 20 | /** 21 | Describes a downloader operation. If one wants to use a custom downloader op, it needs to inherit from `NSOperation` and conform to this protocol 22 | */ 23 | @protocol SDWebImageDownloaderOperationInterface 24 | 25 | - (nonnull instancetype)initWithRequest:(nullable NSURLRequest *)request 26 | inSession:(nullable NSURLSession *)session 27 | options:(SDWebImageDownloaderOptions)options; 28 | 29 | - (nullable id)addHandlersForProgress:(nullable SDWebImageDownloaderProgressBlock)progressBlock 30 | completed:(nullable SDWebImageDownloaderCompletedBlock)completedBlock; 31 | 32 | - (BOOL)shouldDecompressImages; 33 | - (void)setShouldDecompressImages:(BOOL)value; 34 | 35 | - (nullable NSURLCredential *)credential; 36 | - (void)setCredential:(nullable NSURLCredential *)value; 37 | 38 | @end 39 | 40 | 41 | @interface SDWebImageDownloaderOperation : NSOperation 42 | 43 | /** 44 | * The request used by the operation's task. 45 | */ 46 | @property (strong, nonatomic, readonly, nullable) NSURLRequest *request; 47 | 48 | /** 49 | * The operation's task 50 | */ 51 | @property (strong, nonatomic, readonly, nullable) NSURLSessionTask *dataTask; 52 | 53 | 54 | @property (assign, nonatomic) BOOL shouldDecompressImages; 55 | 56 | /** 57 | * Was used to determine whether the URL connection should consult the credential storage for authenticating the connection. 58 | * @deprecated Not used for a couple of versions 59 | */ 60 | @property (nonatomic, assign) BOOL shouldUseCredentialStorage __deprecated_msg("Property deprecated. Does nothing. Kept only for backwards compatibility"); 61 | 62 | /** 63 | * The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. 64 | * 65 | * This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. 66 | */ 67 | @property (nonatomic, strong, nullable) NSURLCredential *credential; 68 | 69 | /** 70 | * The SDWebImageDownloaderOptions for the receiver. 71 | */ 72 | @property (assign, nonatomic, readonly) SDWebImageDownloaderOptions options; 73 | 74 | /** 75 | * The expected size of data. 76 | */ 77 | @property (assign, nonatomic) NSInteger expectedSize; 78 | 79 | /** 80 | * The response returned by the operation's connection. 81 | */ 82 | @property (strong, nonatomic, nullable) NSURLResponse *response; 83 | 84 | /** 85 | * Initializes a `SDWebImageDownloaderOperation` object 86 | * 87 | * @see SDWebImageDownloaderOperation 88 | * 89 | * @param request the URL request 90 | * @param session the URL session in which this operation will run 91 | * @param options downloader options 92 | * 93 | * @return the initialized instance 94 | */ 95 | - (nonnull instancetype)initWithRequest:(nullable NSURLRequest *)request 96 | inSession:(nullable NSURLSession *)session 97 | options:(SDWebImageDownloaderOptions)options NS_DESIGNATED_INITIALIZER; 98 | 99 | /** 100 | * Adds handlers for progress and completion. Returns a tokent that can be passed to -cancel: to cancel this set of 101 | * callbacks. 102 | * 103 | * @param progressBlock the block executed when a new chunk of data arrives. 104 | * @note the progress block is executed on a background queue 105 | * @param completedBlock the block executed when the download is done. 106 | * @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 107 | * 108 | * @return the token to use to cancel this set of handlers 109 | */ 110 | - (nullable id)addHandlersForProgress:(nullable SDWebImageDownloaderProgressBlock)progressBlock 111 | completed:(nullable SDWebImageDownloaderCompletedBlock)completedBlock; 112 | 113 | /** 114 | * Cancels a set of callbacks. Once all callbacks are canceled, the operation is cancelled. 115 | * 116 | * @param token the token representing a set of callbacks to cancel 117 | * 118 | * @return YES if the operation was stopped because this was the last token to be canceled. NO otherwise. 119 | */ 120 | - (BOOL)cancel:(nullable id)token; 121 | 122 | @end 123 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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:(nonnull SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(nullable 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:(nonnull 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, nonnull) 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, nonnull) dispatch_queue_t prefetcherQueue; 65 | 66 | @property (weak, nonatomic, nullable) id delegate; 67 | 68 | /** 69 | * Return the global image prefetcher instance. 70 | */ 71 | + (nonnull instancetype)sharedImagePrefetcher; 72 | 73 | /** 74 | * Allows you to instantiate a prefetcher with any arbitrary image manager. 75 | */ 76 | - (nonnull instancetype)initWithImageManager:(nonnull SDWebImageManager *)manager NS_DESIGNATED_INITIALIZER; 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 | * Any previously-running prefetch operations are canceled. 83 | * 84 | * @param urls list of URLs to prefetch 85 | */ 86 | - (void)prefetchURLs:(nullable NSArray *)urls; 87 | 88 | /** 89 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, 90 | * currently one image is downloaded at a time, 91 | * and skips images for failed downloads and proceed to the next image in the list. 92 | * Any previously-running prefetch operations are canceled. 93 | * 94 | * @param urls list of URLs to prefetch 95 | * @param progressBlock block to be called when progress updates; 96 | * first parameter is the number of completed (successful or not) requests, 97 | * second parameter is the total number of images originally requested to be prefetched 98 | * @param completionBlock block to be called when prefetching is completed 99 | * first param is the number of completed (successful or not) requests, 100 | * second parameter is the number of skipped requests 101 | */ 102 | - (void)prefetchURLs:(nullable NSArray *)urls 103 | progress:(nullable SDWebImagePrefetcherProgressBlock)progressBlock 104 | completed:(nullable SDWebImagePrefetcherCompletionBlock)completionBlock; 105 | 106 | /** 107 | * Remove and cancel queued list 108 | */ 109 | - (void)cancelPrefetching; 110 | 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /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, nonnull) SDWebImageManager *manager; 14 | @property (strong, nonatomic, nullable) 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, nullable) SDWebImagePrefetcherCompletionBlock completionBlock; 20 | @property (copy, nonatomic, nullable) SDWebImagePrefetcherProgressBlock progressBlock; 21 | 22 | @end 23 | 24 | @implementation SDWebImagePrefetcher 25 | 26 | + (nonnull instancetype)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 | - (nonnull instancetype)init { 36 | return [self initWithImageManager:[SDWebImageManager new]]; 37 | } 38 | 39 | - (nonnull instancetype)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 loadImageWithURL:self.prefetchURLs[index] options:self.options progress:nil completed:^(UIImage *image, NSData *data, 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:(nullable NSArray *)urls { 109 | [self prefetchURLs:urls progress:nil completed:nil]; 110 | } 111 | 112 | - (void)prefetchURLs:(nullable NSArray *)urls 113 | progress:(nullable SDWebImagePrefetcherProgressBlock)progressBlock 114 | completed:(nullable SDWebImagePrefetcherCompletionBlock)completionBlock { 115 | [self cancelPrefetching]; // Prevent duplicate prefetch request 116 | self.startedTime = CFAbsoluteTimeGetCurrent(); 117 | self.prefetchURLs = urls; 118 | self.completionBlock = completionBlock; 119 | self.progressBlock = progressBlock; 120 | 121 | if (urls.count == 0) { 122 | if (completionBlock) { 123 | completionBlock(0,0); 124 | } 125 | } else { 126 | // Starts prefetching from the very first image on the list with the max allowed concurrency 127 | NSUInteger listCount = self.prefetchURLs.count; 128 | for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) { 129 | [self startPrefetchingAtIndex:i]; 130 | } 131 | } 132 | } 133 | 134 | - (void)cancelPrefetching { 135 | self.prefetchURLs = nil; 136 | self.skippedCount = 0; 137 | self.requestedCount = 0; 138 | self.finishedCount = 0; 139 | [self.manager cancelAll]; 140 | } 141 | 142 | @end 143 | -------------------------------------------------------------------------------- /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 | 11 | #if SD_UIKIT 12 | 13 | #import "objc/runtime.h" 14 | #import "UIView+WebCacheOperation.h" 15 | #import "UIView+WebCache.h" 16 | 17 | static char imageURLStorageKey; 18 | 19 | typedef NSMutableDictionary SDStateImageURLDictionary; 20 | 21 | @implementation UIButton (WebCache) 22 | 23 | - (nullable NSURL *)sd_currentImageURL { 24 | NSURL *url = self.imageURLStorage[@(self.state)]; 25 | 26 | if (!url) { 27 | url = self.imageURLStorage[@(UIControlStateNormal)]; 28 | } 29 | 30 | return url; 31 | } 32 | 33 | - (nullable NSURL *)sd_imageURLForState:(UIControlState)state { 34 | return self.imageURLStorage[@(state)]; 35 | } 36 | 37 | #pragma mark - Image 38 | 39 | - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state { 40 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; 41 | } 42 | 43 | - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder { 44 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; 45 | } 46 | 47 | - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options { 48 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; 49 | } 50 | 51 | - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state completed:(nullable SDExternalCompletionBlock)completedBlock { 52 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock]; 53 | } 54 | 55 | - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder completed:(nullable SDExternalCompletionBlock)completedBlock { 56 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock]; 57 | } 58 | 59 | - (void)sd_setImageWithURL:(nullable NSURL *)url 60 | forState:(UIControlState)state 61 | placeholderImage:(nullable UIImage *)placeholder 62 | options:(SDWebImageOptions)options 63 | completed:(nullable SDExternalCompletionBlock)completedBlock { 64 | if (!url) { 65 | [self.imageURLStorage removeObjectForKey:@(state)]; 66 | return; 67 | } 68 | 69 | self.imageURLStorage[@(state)] = url; 70 | 71 | __weak typeof(self)weakSelf = self; 72 | [self sd_internalSetImageWithURL:url 73 | placeholderImage:placeholder 74 | options:options 75 | operationKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)] 76 | setImageBlock:^(UIImage *image, NSData *imageData) { 77 | [weakSelf setImage:image forState:state]; 78 | } 79 | progress:nil 80 | completed:completedBlock]; 81 | } 82 | 83 | #pragma mark - Background image 84 | 85 | - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state { 86 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; 87 | } 88 | 89 | - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder { 90 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; 91 | } 92 | 93 | - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options { 94 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; 95 | } 96 | 97 | - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state completed:(nullable SDExternalCompletionBlock)completedBlock { 98 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock]; 99 | } 100 | 101 | - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder completed:(nullable SDExternalCompletionBlock)completedBlock { 102 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock]; 103 | } 104 | 105 | - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url 106 | forState:(UIControlState)state 107 | placeholderImage:(nullable UIImage *)placeholder 108 | options:(SDWebImageOptions)options 109 | completed:(nullable SDExternalCompletionBlock)completedBlock { 110 | if (!url) { 111 | [self.imageURLStorage removeObjectForKey:@(state)]; 112 | return; 113 | } 114 | 115 | self.imageURLStorage[@(state)] = url; 116 | 117 | __weak typeof(self)weakSelf = self; 118 | [self sd_internalSetImageWithURL:url 119 | placeholderImage:placeholder 120 | options:options 121 | operationKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)] 122 | setImageBlock:^(UIImage *image, NSData *imageData) { 123 | [weakSelf setBackgroundImage:image forState:state]; 124 | } 125 | progress:nil 126 | completed:completedBlock]; 127 | } 128 | 129 | - (void)sd_setImageLoadOperation:(id)operation forState:(UIControlState)state { 130 | [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; 131 | } 132 | 133 | - (void)sd_cancelImageLoadForState:(UIControlState)state { 134 | [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; 135 | } 136 | 137 | - (void)sd_setBackgroundImageLoadOperation:(id)operation forState:(UIControlState)state { 138 | [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; 139 | } 140 | 141 | - (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state { 142 | [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; 143 | } 144 | 145 | - (SDStateImageURLDictionary *)imageURLStorage { 146 | SDStateImageURLDictionary *storage = objc_getAssociatedObject(self, &imageURLStorageKey); 147 | if (!storage) { 148 | storage = [NSMutableDictionary dictionary]; 149 | objc_setAssociatedObject(self, &imageURLStorageKey, storage, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 150 | } 151 | 152 | return storage; 153 | } 154 | 155 | @end 156 | 157 | #endif 158 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIImage+GIF.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Laurin Brandner 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 "SDWebImageCompat.h" 11 | 12 | @interface UIImage (GIF) 13 | 14 | /** 15 | * Compatibility method - creates an animated UIImage from an NSData, it will only contain the 1st frame image 16 | */ 17 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data; 18 | 19 | /** 20 | * Checks if an UIImage instance is a GIF. Will use the `images` array 21 | */ 22 | - (BOOL)isGIF; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIImage+GIF.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Laurin Brandner 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 "UIImage+GIF.h" 11 | #import 12 | #import "objc/runtime.h" 13 | #import "NSImage+WebCache.h" 14 | 15 | @implementation UIImage (GIF) 16 | 17 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data { 18 | if (!data) { 19 | return nil; 20 | } 21 | 22 | CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); 23 | 24 | size_t count = CGImageSourceGetCount(source); 25 | 26 | UIImage *staticImage; 27 | 28 | if (count <= 1) { 29 | staticImage = [[UIImage alloc] initWithData:data]; 30 | } else { 31 | // we will only retrieve the 1st frame. the full GIF support is available via the FLAnimatedImageView category. 32 | // this here is only code to allow drawing animated images as static ones 33 | #if SD_WATCH 34 | CGFloat scale = 1; 35 | scale = [WKInterfaceDevice currentDevice].screenScale; 36 | #elif SD_UIKIT 37 | CGFloat scale = 1; 38 | scale = [UIScreen mainScreen].scale; 39 | #endif 40 | 41 | CGImageRef CGImage = CGImageSourceCreateImageAtIndex(source, 0, NULL); 42 | #if SD_UIKIT || SD_WATCH 43 | UIImage *frameImage = [UIImage imageWithCGImage:CGImage scale:scale orientation:UIImageOrientationUp]; 44 | staticImage = [UIImage animatedImageWithImages:@[frameImage] duration:0.0f]; 45 | #elif SD_MAC 46 | staticImage = [[UIImage alloc] initWithCGImage:CGImage size:NSZeroSize]; 47 | #endif 48 | CGImageRelease(CGImage); 49 | } 50 | 51 | CFRelease(source); 52 | 53 | return staticImage; 54 | } 55 | 56 | - (BOOL)isGIF { 57 | return (self.images != nil); 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.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 "NSData+ImageContentType.h" 11 | 12 | @interface UIImage (MultiFormat) 13 | 14 | + (nullable UIImage *)sd_imageWithData:(nullable NSData *)data; 15 | - (nullable NSData *)sd_imageData; 16 | - (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.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 "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 | + (nullable UIImage *)sd_imageWithData:(nullable NSData *)data { 21 | if (!data) { 22 | return nil; 23 | } 24 | 25 | UIImage *image; 26 | SDImageFormat imageFormat = [NSData sd_imageFormatForImageData:data]; 27 | if (imageFormat == SDImageFormatGIF) { 28 | image = [UIImage sd_animatedGIFWithData:data]; 29 | } 30 | #ifdef SD_WEBP 31 | else if (imageFormat == SDImageFormatWebP) 32 | { 33 | image = [UIImage sd_imageWithWebPData:data]; 34 | } 35 | #endif 36 | else { 37 | image = [[UIImage alloc] initWithData:data]; 38 | #if SD_UIKIT || SD_WATCH 39 | UIImageOrientation orientation = [self sd_imageOrientationFromImageData:data]; 40 | if (orientation != UIImageOrientationUp) { 41 | image = [UIImage imageWithCGImage:image.CGImage 42 | scale:image.scale 43 | orientation:orientation]; 44 | } 45 | #endif 46 | } 47 | 48 | 49 | return image; 50 | } 51 | 52 | #if SD_UIKIT || SD_WATCH 53 | +(UIImageOrientation)sd_imageOrientationFromImageData:(nonnull NSData *)imageData { 54 | UIImageOrientation result = UIImageOrientationUp; 55 | CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL); 56 | if (imageSource) { 57 | CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); 58 | if (properties) { 59 | CFTypeRef val; 60 | int exifOrientation; 61 | val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation); 62 | if (val) { 63 | CFNumberGetValue(val, kCFNumberIntType, &exifOrientation); 64 | result = [self sd_exifOrientationToiOSOrientation:exifOrientation]; 65 | } // else - if it's not set it remains at up 66 | CFRelease((CFTypeRef) properties); 67 | } else { 68 | //NSLog(@"NO PROPERTIES, FAIL"); 69 | } 70 | CFRelease(imageSource); 71 | } 72 | return result; 73 | } 74 | 75 | #pragma mark EXIF orientation tag converter 76 | // Convert an EXIF image orientation to an iOS one. 77 | // reference see here: http://sylvana.net/jpegcrop/exif_orientation.html 78 | + (UIImageOrientation) sd_exifOrientationToiOSOrientation:(int)exifOrientation { 79 | UIImageOrientation orientation = UIImageOrientationUp; 80 | switch (exifOrientation) { 81 | case 1: 82 | orientation = UIImageOrientationUp; 83 | break; 84 | 85 | case 3: 86 | orientation = UIImageOrientationDown; 87 | break; 88 | 89 | case 8: 90 | orientation = UIImageOrientationLeft; 91 | break; 92 | 93 | case 6: 94 | orientation = UIImageOrientationRight; 95 | break; 96 | 97 | case 2: 98 | orientation = UIImageOrientationUpMirrored; 99 | break; 100 | 101 | case 4: 102 | orientation = UIImageOrientationDownMirrored; 103 | break; 104 | 105 | case 5: 106 | orientation = UIImageOrientationLeftMirrored; 107 | break; 108 | 109 | case 7: 110 | orientation = UIImageOrientationRightMirrored; 111 | break; 112 | default: 113 | break; 114 | } 115 | return orientation; 116 | } 117 | #endif 118 | 119 | - (nullable NSData *)sd_imageData { 120 | return [self sd_imageDataAsFormat:SDImageFormatUndefined]; 121 | } 122 | 123 | - (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat { 124 | NSData *imageData = nil; 125 | if (self) { 126 | #if SD_UIKIT || SD_WATCH 127 | int alphaInfo = CGImageGetAlphaInfo(self.CGImage); 128 | BOOL hasAlpha = !(alphaInfo == kCGImageAlphaNone || 129 | alphaInfo == kCGImageAlphaNoneSkipFirst || 130 | alphaInfo == kCGImageAlphaNoneSkipLast); 131 | 132 | BOOL usePNG = hasAlpha; 133 | 134 | // the imageFormat param has priority here. But if the format is undefined, we relly on the alpha channel 135 | if (imageFormat != SDImageFormatUndefined) { 136 | usePNG = (imageFormat == SDImageFormatPNG); 137 | } 138 | 139 | if (usePNG) { 140 | imageData = UIImagePNGRepresentation(self); 141 | } else { 142 | imageData = UIImageJPEGRepresentation(self, (CGFloat)1.0); 143 | } 144 | #else 145 | NSBitmapImageFileType imageFileType = NSJPEGFileType; 146 | if (imageFormat == SDImageFormatGIF) { 147 | imageFileType = NSGIFFileType; 148 | } else if (imageFormat == SDImageFormatPNG) { 149 | imageFileType = NSPNGFileType; 150 | } 151 | 152 | imageData = [NSBitmapImageRep representationOfImageRepsInArray:self.representations 153 | usingType:imageFileType 154 | properties:@{}]; 155 | #endif 156 | } 157 | return imageData; 158 | } 159 | 160 | 161 | @end 162 | -------------------------------------------------------------------------------- /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 "SDWebImageCompat.h" 10 | 11 | #if SD_UIKIT 12 | 13 | #import "SDWebImageManager.h" 14 | 15 | /** 16 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView for highlighted state. 17 | */ 18 | @interface UIImageView (HighlightedWebCache) 19 | 20 | /** 21 | * Set the imageView `highlightedImage` with an `url`. 22 | * 23 | * The download is asynchronous and cached. 24 | * 25 | * @param url The url for the image. 26 | */ 27 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url; 28 | 29 | /** 30 | * Set the imageView `highlightedImage` with an `url` and custom options. 31 | * 32 | * The download is asynchronous and cached. 33 | * 34 | * @param url The url for the image. 35 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 36 | */ 37 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url 38 | options:(SDWebImageOptions)options; 39 | 40 | /** 41 | * Set the imageView `highlightedImage` with an `url`. 42 | * 43 | * The download is asynchronous and cached. 44 | * 45 | * @param url The url for the image. 46 | * @param completedBlock A block called when operation has been completed. This block has no return value 47 | * and takes the requested UIImage as first parameter. In case of error the image parameter 48 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 49 | * indicating if the image was retrieved from the local cache or from the network. 50 | * The fourth parameter is the original image url. 51 | */ 52 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url 53 | completed:(nullable SDExternalCompletionBlock)completedBlock; 54 | 55 | /** 56 | * Set the imageView `highlightedImage` with an `url` and custom options. 57 | * 58 | * The download is asynchronous and cached. 59 | * 60 | * @param url The url for the image. 61 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 62 | * @param completedBlock A block called when operation has been completed. This block has no return value 63 | * and takes the requested UIImage as first parameter. In case of error the image parameter 64 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 65 | * indicating if the image was retrieved from the local cache or from the network. 66 | * The fourth parameter is the original image url. 67 | */ 68 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url 69 | options:(SDWebImageOptions)options 70 | completed:(nullable SDExternalCompletionBlock)completedBlock; 71 | 72 | /** 73 | * Set the imageView `highlightedImage` with an `url` and custom options. 74 | * 75 | * The download is asynchronous and cached. 76 | * 77 | * @param url The url for the image. 78 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 79 | * @param progressBlock A block called while image is downloading 80 | * @note the progress block is executed on a background queue 81 | * @param completedBlock A block called when operation has been completed. This block has no return value 82 | * and takes the requested UIImage as first parameter. In case of error the image parameter 83 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 84 | * indicating if the image was retrieved from the local cache or from the network. 85 | * The fourth parameter is the original image url. 86 | */ 87 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url 88 | options:(SDWebImageOptions)options 89 | progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock 90 | completed:(nullable SDExternalCompletionBlock)completedBlock; 91 | 92 | @end 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /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 | 11 | #if SD_UIKIT 12 | 13 | #import "UIView+WebCacheOperation.h" 14 | #import "UIView+WebCache.h" 15 | 16 | @implementation UIImageView (HighlightedWebCache) 17 | 18 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url { 19 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; 20 | } 21 | 22 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url options:(SDWebImageOptions)options { 23 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; 24 | } 25 | 26 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock { 27 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:completedBlock]; 28 | } 29 | 30 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock { 31 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock]; 32 | } 33 | 34 | - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url 35 | options:(SDWebImageOptions)options 36 | progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock 37 | completed:(nullable SDExternalCompletionBlock)completedBlock { 38 | __weak typeof(self)weakSelf = self; 39 | [self sd_internalSetImageWithURL:url 40 | placeholderImage:nil 41 | options:options 42 | operationKey:@"UIImageViewImageOperationHighlighted" 43 | setImageBlock:^(UIImage *image, NSData *imageData) { 44 | weakSelf.highlightedImage = image; 45 | } 46 | progress:progressBlock 47 | completed:completedBlock]; 48 | } 49 | 50 | @end 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /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 | 11 | #if SD_UIKIT || SD_MAC 12 | 13 | #import "SDWebImageManager.h" 14 | 15 | /** 16 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView. 17 | * 18 | * Usage with a UITableViewCell sub-class: 19 | * 20 | * @code 21 | 22 | #import 23 | 24 | ... 25 | 26 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 27 | { 28 | static NSString *MyIdentifier = @"MyIdentifier"; 29 | 30 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 31 | 32 | if (cell == nil) { 33 | cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] 34 | autorelease]; 35 | } 36 | 37 | // Here we use the provided sd_setImageWithURL: method to load the web image 38 | // Ensure you use a placeholder image otherwise cells will be initialized with no image 39 | [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"] 40 | placeholderImage:[UIImage imageNamed:@"placeholder"]]; 41 | 42 | cell.textLabel.text = @"My Text"; 43 | return cell; 44 | } 45 | 46 | * @endcode 47 | */ 48 | @interface UIImageView (WebCache) 49 | 50 | /** 51 | * Set the imageView `image` with an `url`. 52 | * 53 | * The download is asynchronous and cached. 54 | * 55 | * @param url The url for the image. 56 | */ 57 | - (void)sd_setImageWithURL:(nullable NSURL *)url; 58 | 59 | /** 60 | * Set the imageView `image` with an `url` and a placeholder. 61 | * 62 | * The download is asynchronous and cached. 63 | * 64 | * @param url The url for the image. 65 | * @param placeholder The image to be set initially, until the image request finishes. 66 | * @see sd_setImageWithURL:placeholderImage:options: 67 | */ 68 | - (void)sd_setImageWithURL:(nullable NSURL *)url 69 | placeholderImage:(nullable UIImage *)placeholder; 70 | 71 | /** 72 | * Set the imageView `image` with an `url`, placeholder and custom options. 73 | * 74 | * The download is asynchronous and cached. 75 | * 76 | * @param url The url for the image. 77 | * @param placeholder The image to be set initially, until the image request finishes. 78 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 79 | */ 80 | - (void)sd_setImageWithURL:(nullable NSURL *)url 81 | placeholderImage:(nullable UIImage *)placeholder 82 | options:(SDWebImageOptions)options; 83 | 84 | /** 85 | * Set the imageView `image` with an `url`. 86 | * 87 | * The download is asynchronous and cached. 88 | * 89 | * @param url The url for the image. 90 | * @param completedBlock A block called when operation has been completed. This block has no return value 91 | * and takes the requested UIImage as first parameter. In case of error the image parameter 92 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 93 | * indicating if the image was retrieved from the local cache or from the network. 94 | * The fourth parameter is the original image url. 95 | */ 96 | - (void)sd_setImageWithURL:(nullable NSURL *)url 97 | completed:(nullable SDExternalCompletionBlock)completedBlock; 98 | 99 | /** 100 | * Set the imageView `image` with an `url`, placeholder. 101 | * 102 | * The download is asynchronous and cached. 103 | * 104 | * @param url The url for the image. 105 | * @param placeholder The image to be set initially, until the image request finishes. 106 | * @param completedBlock A block called when operation has been completed. This block has no return value 107 | * and takes the requested UIImage as first parameter. In case of error the image parameter 108 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 109 | * indicating if the image was retrieved from the local cache or from the network. 110 | * The fourth parameter is the original image url. 111 | */ 112 | - (void)sd_setImageWithURL:(nullable NSURL *)url 113 | placeholderImage:(nullable UIImage *)placeholder 114 | completed:(nullable SDExternalCompletionBlock)completedBlock; 115 | 116 | /** 117 | * Set the imageView `image` with an `url`, placeholder and custom options. 118 | * 119 | * The download is asynchronous and cached. 120 | * 121 | * @param url The url for the image. 122 | * @param placeholder The image to be set initially, until the image request finishes. 123 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 124 | * @param completedBlock A block called when operation has been completed. This block has no return value 125 | * and takes the requested UIImage as first parameter. In case of error the image parameter 126 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 127 | * indicating if the image was retrieved from the local cache or from the network. 128 | * The fourth parameter is the original image url. 129 | */ 130 | - (void)sd_setImageWithURL:(nullable NSURL *)url 131 | placeholderImage:(nullable UIImage *)placeholder 132 | options:(SDWebImageOptions)options 133 | completed:(nullable SDExternalCompletionBlock)completedBlock; 134 | 135 | /** 136 | * Set the imageView `image` with an `url`, placeholder and custom options. 137 | * 138 | * The download is asynchronous and cached. 139 | * 140 | * @param url The url for the image. 141 | * @param placeholder The image to be set initially, until the image request finishes. 142 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 143 | * @param progressBlock A block called while image is downloading 144 | * @note the progress block is executed on a background queue 145 | * @param completedBlock A block called when operation has been completed. This block has no return value 146 | * and takes the requested UIImage as first parameter. In case of error the image parameter 147 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 148 | * indicating if the image was retrieved from the local cache or from the network. 149 | * The fourth parameter is the original image url. 150 | */ 151 | - (void)sd_setImageWithURL:(nullable NSURL *)url 152 | placeholderImage:(nullable UIImage *)placeholder 153 | options:(SDWebImageOptions)options 154 | progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock 155 | completed:(nullable SDExternalCompletionBlock)completedBlock; 156 | 157 | /** 158 | * Set the imageView `image` with an `url` and optionally a placeholder image. 159 | * 160 | * The download is asynchronous and cached. 161 | * 162 | * @param url The url for the image. 163 | * @param placeholder The image to be set initially, until the image request finishes. 164 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 165 | * @param progressBlock A block called while image is downloading 166 | * @note the progress block is executed on a background queue 167 | * @param completedBlock A block called when operation has been completed. This block has no return value 168 | * and takes the requested UIImage as first parameter. In case of error the image parameter 169 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 170 | * indicating if the image was retrieved from the local cache or from the network. 171 | * The fourth parameter is the original image url. 172 | */ 173 | - (void)sd_setImageWithPreviousCachedImageWithURL:(nullable NSURL *)url 174 | placeholderImage:(nullable UIImage *)placeholder 175 | options:(SDWebImageOptions)options 176 | progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock 177 | completed:(nullable SDExternalCompletionBlock)completedBlock; 178 | 179 | #if SD_UIKIT 180 | 181 | #pragma mark - Animation of multiple images 182 | 183 | /** 184 | * Download an array of images and starts them in an animation loop 185 | * 186 | * @param arrayOfURLs An array of NSURL 187 | */ 188 | - (void)sd_setAnimationImagesWithURLs:(nonnull NSArray *)arrayOfURLs; 189 | 190 | - (void)sd_cancelCurrentAnimationImagesLoad; 191 | 192 | #endif 193 | 194 | @end 195 | 196 | #endif 197 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIImageView+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 "UIImageView+WebCache.h" 10 | 11 | #if SD_UIKIT || SD_MAC 12 | 13 | #import "objc/runtime.h" 14 | #import "UIView+WebCacheOperation.h" 15 | #import "UIView+WebCache.h" 16 | 17 | @implementation UIImageView (WebCache) 18 | 19 | - (void)sd_setImageWithURL:(nullable NSURL *)url { 20 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; 21 | } 22 | 23 | - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder { 24 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil]; 25 | } 26 | 27 | - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options { 28 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil]; 29 | } 30 | 31 | - (void)sd_setImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock { 32 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock]; 33 | } 34 | 35 | - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder completed:(nullable SDExternalCompletionBlock)completedBlock { 36 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:completedBlock]; 37 | } 38 | 39 | - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock { 40 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; 41 | } 42 | 43 | - (void)sd_setImageWithURL:(nullable NSURL *)url 44 | placeholderImage:(nullable UIImage *)placeholder 45 | options:(SDWebImageOptions)options 46 | progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock 47 | completed:(nullable SDExternalCompletionBlock)completedBlock { 48 | [self sd_internalSetImageWithURL:url 49 | placeholderImage:placeholder 50 | options:options 51 | operationKey:nil 52 | setImageBlock:nil 53 | progress:progressBlock 54 | completed:completedBlock]; 55 | } 56 | 57 | - (void)sd_setImageWithPreviousCachedImageWithURL:(nullable NSURL *)url 58 | placeholderImage:(nullable UIImage *)placeholder 59 | options:(SDWebImageOptions)options 60 | progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock 61 | completed:(nullable SDExternalCompletionBlock)completedBlock { 62 | NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:url]; 63 | UIImage *lastPreviousCachedImage = [[SDImageCache sharedImageCache] imageFromCacheForKey:key]; 64 | 65 | [self sd_setImageWithURL:url placeholderImage:lastPreviousCachedImage ?: placeholder options:options progress:progressBlock completed:completedBlock]; 66 | } 67 | 68 | #if SD_UIKIT 69 | 70 | #pragma mark - Animation of multiple images 71 | 72 | - (void)sd_setAnimationImagesWithURLs:(nonnull NSArray *)arrayOfURLs { 73 | [self sd_cancelCurrentAnimationImagesLoad]; 74 | __weak __typeof(self)wself = self; 75 | 76 | NSMutableArray> *operationsArray = [[NSMutableArray alloc] init]; 77 | 78 | for (NSURL *logoImageURL in arrayOfURLs) { 79 | id operation = [SDWebImageManager.sharedManager loadImageWithURL:logoImageURL options:0 progress:nil completed:^(UIImage *image, NSData *data, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 80 | if (!wself) return; 81 | dispatch_main_async_safe(^{ 82 | __strong UIImageView *sself = wself; 83 | [sself stopAnimating]; 84 | if (sself && image) { 85 | NSMutableArray *currentImages = [[sself animationImages] mutableCopy]; 86 | if (!currentImages) { 87 | currentImages = [[NSMutableArray alloc] init]; 88 | } 89 | [currentImages addObject:image]; 90 | 91 | sself.animationImages = currentImages; 92 | [sself setNeedsLayout]; 93 | } 94 | [sself startAnimating]; 95 | }); 96 | }]; 97 | [operationsArray addObject:operation]; 98 | } 99 | 100 | [self sd_setImageLoadOperation:[operationsArray copy] forKey:@"UIImageViewAnimationImages"]; 101 | } 102 | 103 | - (void)sd_cancelCurrentAnimationImagesLoad { 104 | [self sd_cancelImageLoadOperationWithKey:@"UIImageViewAnimationImages"]; 105 | } 106 | #endif 107 | 108 | @end 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIView+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 | 11 | #if SD_UIKIT || SD_MAC 12 | 13 | #import "SDWebImageManager.h" 14 | 15 | typedef void(^SDSetImageBlock)(UIImage * _Nullable image, NSData * _Nullable imageData); 16 | 17 | @interface UIView (WebCache) 18 | 19 | /** 20 | * Get the current image URL. 21 | * 22 | * Note that because of the limitations of categories this property can get out of sync 23 | * if you use setImage: directly. 24 | */ 25 | - (nullable NSURL *)sd_imageURL; 26 | 27 | /** 28 | * Set the imageView `image` with an `url` and optionally a placeholder image. 29 | * 30 | * The download is asynchronous and cached. 31 | * 32 | * @param url The url for the image. 33 | * @param placeholder The image to be set initially, until the image request finishes. 34 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 35 | * @param operationKey A string to be used as the operation key. If nil, will use the class name 36 | * @param setImageBlock Block used for custom set image code 37 | * @param progressBlock A block called while image is downloading 38 | * @note the progress block is executed on a background queue 39 | * @param completedBlock A block called when operation has been completed. This block has no return value 40 | * and takes the requested UIImage as first parameter. In case of error the image parameter 41 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 42 | * indicating if the image was retrieved from the local cache or from the network. 43 | * The fourth parameter is the original image url. 44 | */ 45 | - (void)sd_internalSetImageWithURL:(nullable NSURL *)url 46 | placeholderImage:(nullable UIImage *)placeholder 47 | options:(SDWebImageOptions)options 48 | operationKey:(nullable NSString *)operationKey 49 | setImageBlock:(nullable SDSetImageBlock)setImageBlock 50 | progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock 51 | completed:(nullable SDExternalCompletionBlock)completedBlock; 52 | 53 | /** 54 | * Cancel the current download 55 | */ 56 | - (void)sd_cancelCurrentImageLoad; 57 | 58 | #if SD_UIKIT 59 | 60 | #pragma mark - Activity indicator 61 | 62 | /** 63 | * Show activity UIActivityIndicatorView 64 | */ 65 | - (void)sd_setShowActivityIndicatorView:(BOOL)show; 66 | 67 | /** 68 | * set desired UIActivityIndicatorViewStyle 69 | * 70 | * @param style The style of the UIActivityIndicatorView 71 | */ 72 | - (void)sd_setIndicatorStyle:(UIActivityIndicatorViewStyle)style; 73 | 74 | - (BOOL)sd_showActivityIndicatorView; 75 | - (void)sd_addActivityIndicator; 76 | - (void)sd_removeActivityIndicator; 77 | 78 | #endif 79 | 80 | @end 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIView+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 "UIView+WebCache.h" 10 | 11 | #if SD_UIKIT || SD_MAC 12 | 13 | #import "objc/runtime.h" 14 | #import "UIView+WebCacheOperation.h" 15 | 16 | static char imageURLKey; 17 | 18 | #if SD_UIKIT 19 | static char TAG_ACTIVITY_INDICATOR; 20 | static char TAG_ACTIVITY_STYLE; 21 | #endif 22 | static char TAG_ACTIVITY_SHOW; 23 | 24 | @implementation UIView (WebCache) 25 | 26 | - (nullable NSURL *)sd_imageURL { 27 | return objc_getAssociatedObject(self, &imageURLKey); 28 | } 29 | 30 | - (void)sd_internalSetImageWithURL:(nullable NSURL *)url 31 | placeholderImage:(nullable UIImage *)placeholder 32 | options:(SDWebImageOptions)options 33 | operationKey:(nullable NSString *)operationKey 34 | setImageBlock:(nullable SDSetImageBlock)setImageBlock 35 | progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock 36 | completed:(nullable SDExternalCompletionBlock)completedBlock { 37 | NSString *validOperationKey = operationKey ?: NSStringFromClass([self class]); 38 | [self sd_cancelImageLoadOperationWithKey:validOperationKey]; 39 | objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 40 | 41 | if (!(options & SDWebImageDelayPlaceholder)) { 42 | dispatch_main_async_safe(^{ 43 | [self sd_setImage:placeholder imageData:nil basedOnClassOrViaCustomSetImageBlock:setImageBlock]; 44 | }); 45 | } 46 | 47 | if (url) { 48 | // check if activityView is enabled or not 49 | if ([self sd_showActivityIndicatorView]) { 50 | [self sd_addActivityIndicator]; 51 | } 52 | 53 | __weak __typeof(self)wself = self; 54 | id operation = [SDWebImageManager.sharedManager loadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSData *data, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 55 | __strong __typeof (wself) sself = wself; 56 | [sself sd_removeActivityIndicator]; 57 | if (!sself) { 58 | return; 59 | } 60 | dispatch_main_async_safe(^{ 61 | if (!sself) { 62 | return; 63 | } 64 | if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock) { 65 | completedBlock(image, error, cacheType, url); 66 | return; 67 | } else if (image) { 68 | [sself sd_setImage:image imageData:data basedOnClassOrViaCustomSetImageBlock:setImageBlock]; 69 | [sself sd_setNeedsLayout]; 70 | } else { 71 | if ((options & SDWebImageDelayPlaceholder)) { 72 | [sself sd_setImage:placeholder imageData:nil basedOnClassOrViaCustomSetImageBlock:setImageBlock]; 73 | [sself sd_setNeedsLayout]; 74 | } 75 | } 76 | if (completedBlock && finished) { 77 | completedBlock(image, error, cacheType, url); 78 | } 79 | }); 80 | }]; 81 | [self sd_setImageLoadOperation:operation forKey:validOperationKey]; 82 | } else { 83 | dispatch_main_async_safe(^{ 84 | [self sd_removeActivityIndicator]; 85 | if (completedBlock) { 86 | NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; 87 | completedBlock(nil, error, SDImageCacheTypeNone, url); 88 | } 89 | }); 90 | } 91 | } 92 | 93 | - (void)sd_cancelCurrentImageLoad { 94 | [self sd_cancelImageLoadOperationWithKey:NSStringFromClass([self class])]; 95 | } 96 | 97 | - (void)sd_setImage:(UIImage *)image imageData:(NSData *)imageData basedOnClassOrViaCustomSetImageBlock:(SDSetImageBlock)setImageBlock { 98 | if (setImageBlock) { 99 | setImageBlock(image, imageData); 100 | return; 101 | } 102 | 103 | #if SD_UIKIT || SD_MAC 104 | if ([self isKindOfClass:[UIImageView class]]) { 105 | UIImageView *imageView = (UIImageView *)self; 106 | imageView.image = image; 107 | } 108 | #endif 109 | 110 | #if SD_UIKIT 111 | if ([self isKindOfClass:[UIButton class]]) { 112 | UIButton *button = (UIButton *)self; 113 | [button setImage:image forState:UIControlStateNormal]; 114 | } 115 | #endif 116 | } 117 | 118 | - (void)sd_setNeedsLayout { 119 | #if SD_UIKIT 120 | [self setNeedsLayout]; 121 | #elif SD_MAC 122 | [self setNeedsLayout:YES]; 123 | #endif 124 | } 125 | 126 | #pragma mark - Activity indicator 127 | 128 | #pragma mark - 129 | #if SD_UIKIT 130 | - (UIActivityIndicatorView *)activityIndicator { 131 | return (UIActivityIndicatorView *)objc_getAssociatedObject(self, &TAG_ACTIVITY_INDICATOR); 132 | } 133 | 134 | - (void)setActivityIndicator:(UIActivityIndicatorView *)activityIndicator { 135 | objc_setAssociatedObject(self, &TAG_ACTIVITY_INDICATOR, activityIndicator, OBJC_ASSOCIATION_RETAIN); 136 | } 137 | #endif 138 | 139 | - (void)sd_setShowActivityIndicatorView:(BOOL)show { 140 | objc_setAssociatedObject(self, &TAG_ACTIVITY_SHOW, @(show), OBJC_ASSOCIATION_RETAIN); 141 | } 142 | 143 | - (BOOL)sd_showActivityIndicatorView { 144 | return [objc_getAssociatedObject(self, &TAG_ACTIVITY_SHOW) boolValue]; 145 | } 146 | 147 | #if SD_UIKIT 148 | - (void)sd_setIndicatorStyle:(UIActivityIndicatorViewStyle)style{ 149 | objc_setAssociatedObject(self, &TAG_ACTIVITY_STYLE, [NSNumber numberWithInt:style], OBJC_ASSOCIATION_RETAIN); 150 | } 151 | 152 | - (int)sd_getIndicatorStyle{ 153 | return [objc_getAssociatedObject(self, &TAG_ACTIVITY_STYLE) intValue]; 154 | } 155 | #endif 156 | 157 | - (void)sd_addActivityIndicator { 158 | #if SD_UIKIT 159 | if (!self.activityIndicator) { 160 | self.activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:[self sd_getIndicatorStyle]]; 161 | self.activityIndicator.translatesAutoresizingMaskIntoConstraints = NO; 162 | 163 | dispatch_main_async_safe(^{ 164 | [self addSubview:self.activityIndicator]; 165 | 166 | [self addConstraint:[NSLayoutConstraint constraintWithItem:self.activityIndicator 167 | attribute:NSLayoutAttributeCenterX 168 | relatedBy:NSLayoutRelationEqual 169 | toItem:self 170 | attribute:NSLayoutAttributeCenterX 171 | multiplier:1.0 172 | constant:0.0]]; 173 | [self addConstraint:[NSLayoutConstraint constraintWithItem:self.activityIndicator 174 | attribute:NSLayoutAttributeCenterY 175 | relatedBy:NSLayoutRelationEqual 176 | toItem:self 177 | attribute:NSLayoutAttributeCenterY 178 | multiplier:1.0 179 | constant:0.0]]; 180 | }); 181 | } 182 | 183 | dispatch_main_async_safe(^{ 184 | [self.activityIndicator startAnimating]; 185 | }); 186 | #endif 187 | } 188 | 189 | - (void)sd_removeActivityIndicator { 190 | #if SD_UIKIT 191 | if (self.activityIndicator) { 192 | [self.activityIndicator removeFromSuperview]; 193 | self.activityIndicator = nil; 194 | } 195 | #endif 196 | } 197 | 198 | @end 199 | 200 | #endif 201 | -------------------------------------------------------------------------------- /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 "SDWebImageCompat.h" 10 | 11 | #if SD_UIKIT || SD_MAC 12 | 13 | #import "SDWebImageManager.h" 14 | 15 | @interface UIView (WebCacheOperation) 16 | 17 | /** 18 | * Set the image load operation (storage in a UIView based dictionary) 19 | * 20 | * @param operation the operation 21 | * @param key key for storing the operation 22 | */ 23 | - (void)sd_setImageLoadOperation:(nullable id)operation forKey:(nullable NSString *)key; 24 | 25 | /** 26 | * Cancel all operations for the current UIView and key 27 | * 28 | * @param key key for identifying the operations 29 | */ 30 | - (void)sd_cancelImageLoadOperationWithKey:(nullable NSString *)key; 31 | 32 | /** 33 | * Just remove the operations corresponding to the current UIView and key without cancelling them 34 | * 35 | * @param key key for identifying the operations 36 | */ 37 | - (void)sd_removeImageLoadOperationWithKey:(nullable NSString *)key; 38 | 39 | @end 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /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 | 11 | #if SD_UIKIT || SD_MAC 12 | 13 | #import "objc/runtime.h" 14 | 15 | static char loadOperationKey; 16 | 17 | typedef NSMutableDictionary SDOperationsDictionary; 18 | 19 | @implementation UIView (WebCacheOperation) 20 | 21 | - (SDOperationsDictionary *)operationDictionary { 22 | SDOperationsDictionary *operations = objc_getAssociatedObject(self, &loadOperationKey); 23 | if (operations) { 24 | return operations; 25 | } 26 | operations = [NSMutableDictionary dictionary]; 27 | objc_setAssociatedObject(self, &loadOperationKey, operations, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 28 | return operations; 29 | } 30 | 31 | - (void)sd_setImageLoadOperation:(nullable id)operation forKey:(nullable NSString *)key { 32 | if (key) { 33 | [self sd_cancelImageLoadOperationWithKey:key]; 34 | if (operation) { 35 | SDOperationsDictionary *operationDictionary = [self operationDictionary]; 36 | operationDictionary[key] = operation; 37 | } 38 | } 39 | } 40 | 41 | - (void)sd_cancelImageLoadOperationWithKey:(nullable NSString *)key { 42 | // Cancel in progress downloader from queue 43 | SDOperationsDictionary *operationDictionary = [self operationDictionary]; 44 | id operations = operationDictionary[key]; 45 | if (operations) { 46 | if ([operations isKindOfClass:[NSArray class]]) { 47 | for (id operation in operations) { 48 | if (operation) { 49 | [operation cancel]; 50 | } 51 | } 52 | } else if ([operations conformsToProtocol:@protocol(SDWebImageOperation)]){ 53 | [(id) operations cancel]; 54 | } 55 | [operationDictionary removeObjectForKey:key]; 56 | } 57 | } 58 | 59 | - (void)sd_removeImageLoadOperationWithKey:(nullable NSString *)key { 60 | if (key) { 61 | SDOperationsDictionary *operationDictionary = [self operationDictionary]; 62 | [operationDictionary removeObjectForKey:key]; 63 | } 64 | } 65 | 66 | @end 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ADPageViewDemo/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 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ADPageViewDemo/Pods-ADPageViewDemo-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## SDAutoLayout 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (c) 2015 GSD_iOS 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | 29 | 30 | ## SDWebImage 31 | 32 | Copyright (c) 2016 Olivier Poitrey rs@dailymotion.com 33 | 34 | Permission is hereby granted, free of charge, to any person obtaining a copy 35 | of this software and associated documentation files (the "Software"), to deal 36 | in the Software without restriction, including without limitation the rights 37 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 38 | copies of the Software, and to permit persons to whom the Software is furnished 39 | to do so, subject to the following conditions: 40 | 41 | The above copyright notice and this permission notice shall be included in all 42 | copies or substantial portions of the Software. 43 | 44 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 45 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 46 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 47 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 48 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 49 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 50 | THE SOFTWARE. 51 | 52 | 53 | Generated by CocoaPods - https://cocoapods.org 54 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ADPageViewDemo/Pods-ADPageViewDemo-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 | The MIT License (MIT) 18 | 19 | Copyright (c) 2015 GSD_iOS 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in all 29 | copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 37 | SOFTWARE. 38 | 39 | 40 | License 41 | MIT 42 | Title 43 | SDAutoLayout 44 | Type 45 | PSGroupSpecifier 46 | 47 | 48 | FooterText 49 | Copyright (c) 2016 Olivier Poitrey rs@dailymotion.com 50 | 51 | Permission is hereby granted, free of charge, to any person obtaining a copy 52 | of this software and associated documentation files (the "Software"), to deal 53 | in the Software without restriction, including without limitation the rights 54 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 55 | copies of the Software, and to permit persons to whom the Software is furnished 56 | to do so, subject to the following conditions: 57 | 58 | The above copyright notice and this permission notice shall be included in all 59 | copies or substantial portions of the Software. 60 | 61 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 62 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 63 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 64 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 65 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 66 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 67 | THE SOFTWARE. 68 | 69 | 70 | License 71 | MIT 72 | Title 73 | SDWebImage 74 | Type 75 | PSGroupSpecifier 76 | 77 | 78 | FooterText 79 | Generated by CocoaPods - https://cocoapods.org 80 | Title 81 | 82 | Type 83 | PSGroupSpecifier 84 | 85 | 86 | StringsTable 87 | Acknowledgements 88 | Title 89 | Acknowledgements 90 | 91 | 92 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ADPageViewDemo/Pods-ADPageViewDemo-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_ADPageViewDemo : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_ADPageViewDemo 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ADPageViewDemo/Pods-ADPageViewDemo-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 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 10 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 11 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 12 | 13 | install_framework() 14 | { 15 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 16 | local source="${BUILT_PRODUCTS_DIR}/$1" 17 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 18 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 19 | elif [ -r "$1" ]; then 20 | local source="$1" 21 | fi 22 | 23 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 24 | 25 | if [ -L "${source}" ]; then 26 | echo "Symlinked..." 27 | source="$(readlink "${source}")" 28 | fi 29 | 30 | # Use filter instead of exclude so missing patterns don't throw errors. 31 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 32 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 33 | 34 | local basename 35 | basename="$(basename -s .framework "$1")" 36 | binary="${destination}/${basename}.framework/${basename}" 37 | if ! [ -r "$binary" ]; then 38 | binary="${destination}/${basename}" 39 | fi 40 | 41 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 42 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 43 | strip_invalid_archs "$binary" 44 | fi 45 | 46 | # Resign the code if required by the build settings to avoid unstable apps 47 | code_sign_if_enabled "${destination}/$(basename "$1")" 48 | 49 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 50 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 51 | local swift_runtime_libs 52 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 53 | for lib in $swift_runtime_libs; do 54 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 55 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 56 | code_sign_if_enabled "${destination}/${lib}" 57 | done 58 | fi 59 | } 60 | 61 | # Copies the dSYM of a vendored framework 62 | install_dsym() { 63 | local source="$1" 64 | if [ -r "$source" ]; then 65 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DWARF_DSYM_FOLDER_PATH}\"" 66 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DWARF_DSYM_FOLDER_PATH}" 67 | fi 68 | } 69 | 70 | # Signs a framework with the provided identity 71 | code_sign_if_enabled() { 72 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 73 | # Use the current code_sign_identitiy 74 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 75 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" 76 | 77 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 78 | code_sign_cmd="$code_sign_cmd &" 79 | fi 80 | echo "$code_sign_cmd" 81 | eval "$code_sign_cmd" 82 | fi 83 | } 84 | 85 | # Strip invalid architectures 86 | strip_invalid_archs() { 87 | binary="$1" 88 | # Get architectures for current file 89 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 90 | stripped="" 91 | for arch in $archs; do 92 | if ! [[ "${ARCHS}" == *"$arch"* ]]; then 93 | # Strip non-valid architectures in-place 94 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 95 | stripped="$stripped $arch" 96 | fi 97 | done 98 | if [[ "$stripped" ]]; then 99 | echo "Stripped $binary of architectures:$stripped" 100 | fi 101 | } 102 | 103 | 104 | if [[ "$CONFIGURATION" == "Debug" ]]; then 105 | install_framework "${BUILT_PRODUCTS_DIR}/SDAutoLayout/SDAutoLayout.framework" 106 | install_framework "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework" 107 | fi 108 | if [[ "$CONFIGURATION" == "Release" ]]; then 109 | install_framework "${BUILT_PRODUCTS_DIR}/SDAutoLayout/SDAutoLayout.framework" 110 | install_framework "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework" 111 | fi 112 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 113 | wait 114 | fi 115 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ADPageViewDemo/Pods-ADPageViewDemo-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 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 12 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 13 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 14 | 15 | case "${TARGETED_DEVICE_FAMILY}" in 16 | 1,2) 17 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 18 | ;; 19 | 1) 20 | TARGET_DEVICE_ARGS="--target-device iphone" 21 | ;; 22 | 2) 23 | TARGET_DEVICE_ARGS="--target-device ipad" 24 | ;; 25 | 3) 26 | TARGET_DEVICE_ARGS="--target-device tv" 27 | ;; 28 | 4) 29 | TARGET_DEVICE_ARGS="--target-device watch" 30 | ;; 31 | *) 32 | TARGET_DEVICE_ARGS="--target-device mac" 33 | ;; 34 | esac 35 | 36 | install_resource() 37 | { 38 | if [[ "$1" = /* ]] ; then 39 | RESOURCE_PATH="$1" 40 | else 41 | RESOURCE_PATH="${PODS_ROOT}/$1" 42 | fi 43 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 44 | cat << EOM 45 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 46 | EOM 47 | exit 1 48 | fi 49 | case $RESOURCE_PATH in 50 | *.storyboard) 51 | 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}" || true 52 | 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} 53 | ;; 54 | *.xib) 55 | 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}" || true 56 | 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} 57 | ;; 58 | *.framework) 59 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true 60 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 61 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true 62 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 63 | ;; 64 | *.xcdatamodel) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 67 | ;; 68 | *.xcdatamodeld) 69 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true 70 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 71 | ;; 72 | *.xcmappingmodel) 73 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true 74 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 75 | ;; 76 | *.xcassets) 77 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 78 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 79 | ;; 80 | *) 81 | echo "$RESOURCE_PATH" || true 82 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 83 | ;; 84 | esac 85 | } 86 | 87 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 89 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 90 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 91 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 92 | fi 93 | rm -f "$RESOURCES_TO_COPY" 94 | 95 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 96 | then 97 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 98 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 99 | while read line; do 100 | if [[ $line != "${PODS_ROOT}*" ]]; then 101 | XCASSET_FILES+=("$line") 102 | fi 103 | done <<<"$OTHER_XCASSETS" 104 | 105 | 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}" 106 | fi 107 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ADPageViewDemo/Pods-ADPageViewDemo-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_ADPageViewDemoVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_ADPageViewDemoVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ADPageViewDemo/Pods-ADPageViewDemo.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SDAutoLayout" "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/SDAutoLayout/SDAutoLayout.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage/SDWebImage.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "SDAutoLayout" -framework "SDWebImage" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ADPageViewDemo/Pods-ADPageViewDemo.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_ADPageViewDemo { 2 | umbrella header "Pods-ADPageViewDemo-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ADPageViewDemo/Pods-ADPageViewDemo.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SDAutoLayout" "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/SDAutoLayout/SDAutoLayout.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage/SDWebImage.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "SDAutoLayout" -framework "SDWebImage" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDAutoLayout/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 | FMWK 17 | CFBundleShortVersionString 18 | 2.2.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDAutoLayout/SDAutoLayout-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_SDAutoLayout : NSObject 3 | @end 4 | @implementation PodsDummy_SDAutoLayout 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDAutoLayout/SDAutoLayout-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDAutoLayout/SDAutoLayout-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "SDAutoLayout.h" 14 | #import "UITableView+SDAutoTableViewCellHeight.h" 15 | #import "UIView+SDAutoLayout.h" 16 | 17 | FOUNDATION_EXPORT double SDAutoLayoutVersionNumber; 18 | FOUNDATION_EXPORT const unsigned char SDAutoLayoutVersionString[]; 19 | 20 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDAutoLayout/SDAutoLayout.modulemap: -------------------------------------------------------------------------------- 1 | framework module SDAutoLayout { 2 | umbrella header "SDAutoLayout-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDAutoLayout/SDAutoLayout.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/SDAutoLayout 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/SDAutoLayout 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/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 | FMWK 17 | CFBundleShortVersionString 18 | 4.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/SDWebImage-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_SDWebImage : NSObject 3 | @end 4 | @implementation PodsDummy_SDWebImage 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/SDWebImage-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "NSData+ImageContentType.h" 14 | #import "NSImage+WebCache.h" 15 | #import "SDImageCache.h" 16 | #import "SDImageCacheConfig.h" 17 | #import "SDWebImageCompat.h" 18 | #import "SDWebImageDecoder.h" 19 | #import "SDWebImageDownloader.h" 20 | #import "SDWebImageDownloaderOperation.h" 21 | #import "SDWebImageManager.h" 22 | #import "SDWebImageOperation.h" 23 | #import "SDWebImagePrefetcher.h" 24 | #import "UIButton+WebCache.h" 25 | #import "UIImage+GIF.h" 26 | #import "UIImage+MultiFormat.h" 27 | #import "UIImageView+HighlightedWebCache.h" 28 | #import "UIImageView+WebCache.h" 29 | #import "UIView+WebCache.h" 30 | #import "UIView+WebCacheOperation.h" 31 | 32 | FOUNDATION_EXPORT double SDWebImageVersionNumber; 33 | FOUNDATION_EXPORT const unsigned char SDWebImageVersionString[]; 34 | 35 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/SDWebImage.modulemap: -------------------------------------------------------------------------------- 1 | framework module SDWebImage { 2 | umbrella header "SDWebImage-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /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/Public" 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 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/SDWebImage 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ADPageViewDemo 2 | ## 效果图 3 | 4 | ![gif1](https://github.com/CCBrother/ADPageViewDemo/blob/master/show1.gif) 5 | ![gif2](https://github.com/CCBrother/ADPageViewDemo/blob/master/show2.gif) 6 | 7 | 8 | ## 一、广告页功能思路 9 | * APP第一次安装或版本更新时,有引导页的时候不展示广告,第二次开始展示广告 10 | 11 | * 创建一个展示广告的Imageview 12 | 13 | * 添加跳过广告的倒计时按钮 14 | 15 | * 添加广告页面点击事件,点击广告图片跳转到响应页面;广告链接地址也需要用NSUserDefaults存储。注意:广告详情页面是从首页push进去的 16 | 17 | * 加载:在启动页展示的时间里,开始加载广告,先将图片通过SD异步下载到本地,并保存图片名,每次打开app时先根据本地存储的图片名查找沙盒中是否存在该图片,如果存在,则显示广告页。在启动页加载完成之后应该去判断广告是否有加载出来 18 | 19 | * 判断广告图片是否更新:无论本地是否存在广告图片,每次启动都需要重新调用广告接口,根据图片名称或者图片id等方法判断广告是否更新,如果获取的图片名称或者图片id跟本地存储的不一致,则需要重新下载新图片,并删除旧图片 20 | 21 | * 广告页面的底部和启动图的底部一般都是相同的,给我们的感觉就是启动图加载完之后把广告图放在了启动图上,而且不能有偏差,比如下图淘宝启动画面。美工在制作广告图的时候要注意这点 22 | 23 | * APP在后台:如果app在后台待机太久,再次进来前台的时候也应该展示广告,所以在applicationDidEnterBackground的时候应该把时间存起来。在applicationWillEnterForeground的时候对比时间差,判断是否显示 24 | 25 | * 增加广告显示开关:后台在开发广告api的时候可以增加一个字段来判断是否启用广告,如果后台关闭了广告,将沙盒中的图片删除即可 26 | 27 | * 添加统计:看广告详情有多少人观看,有多少人会跳过等 28 | 29 | ## 二、步骤 30 | #### 1、首先判断APP是否是第一次进入或者版本更新,如果是,启动引导页;如果不是,再判断是否需要显示广告。 31 | ``` 32 | if ([Manager isFirstLaunch]) { 33 | //一句代码启动引导页 34 | [GuidePageView sharedWithImages:@[@"1.jpg",@"2.jpg",@"3.jpg",@"4.jpg"] buttonImage:@"post_normal" buttonFrame:CGRectMake(0, -10, SCREEN_WIDTH, SCREEN_HEIGHT)];` 35 | }else { 36 | //显示广告页 37 | //后台在开发广告api的时候增加一个字段来判断是否启用广告 38 | if (self.isShowAdPage) {} 39 | //一句代码调用广告页 40 | [ADPageView showAdPageView]; 41 | } 42 | ``` 43 | #### 2、创建一个展示广告的Imageview和添加跳过广告的倒计时按钮 44 | ``` 45 | - (instancetype)initWithFrame:(CGRect)frame { 46 | if (self = [super initWithFrame:frame]) { 47 | //广告页 48 | _adView = [[UIImageView alloc] initWithFrame:frame]; 49 | _adView.userInteractionEnabled = YES; 50 | _adView.contentMode = UIViewContentModeScaleAspectFit; 51 | _adView.clipsToBounds = YES; 52 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushToAd)]; 53 | [_adView addGestureRecognizer:tap]; 54 | 55 | //跳过按钮 56 | _skipBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 57 | _skipBtn.backgroundColor = RGBAColor(38, 38, 38, 0.6); 58 | _skipBtn.layer.cornerRadius = 4; 59 | [_skipBtn setTitle:[NSString stringWithFormat:@"跳过%d",showTime] forState:UIControlStateNormal]; 60 | [_skipBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 61 | _skipBtn.titleLabel.font = [UIFont systemFontOfSize:15.0f]; 62 | [_skipBtn addTarget:self action:@selector(dismissAdView) forControlEvents:UIControlEventTouchUpInside]; 63 | 64 | [self addSubview:_adView]; 65 | [self addSubview:_skipBtn]; 66 | _skipBtn.sd_layout 67 | .widthIs(60) 68 | .heightIs(30) 69 | .topSpaceToView(self, 20) 70 | .rightSpaceToView(self, 20); 71 | 72 | [self showAdView]; 73 | } 74 | return self; 75 | } 76 | ``` 77 | #### 3、广告页加载,先从SD缓存查找,有,则显示,并下载更新,删除旧图片;没有,下载,保存。 78 | ``` 79 | - (void)showAdView { 80 | 81 | SDWebImageManager *imageManager = [SDWebImageManager sharedManager]; 82 | //先从sd缓存读取,有则显示 83 | NSString *imagePath = [[imageManager imageCache] defaultCachePathForKey:adImageName]; 84 | NSData * imageData = [NSData dataWithContentsOfFile:imagePath]; 85 | 86 | if (imageData) { 87 | [self adViewWithData:imageData]; 88 | } 89 | 90 | NSArray *imageArray = @[@"http://img.hb.aicdn.com/4cdbe766dc5a206da266a262ee87d9e5cf19eafb26a9d-xqBO2L_fw658", @"http://img.hb.aicdn.com/926c595bfb97b663077940b6598f63fa318dda092c174-hmqXI3_fw658", @"http://img.hb.aicdn.com/0e0d63ad054e9d48a3abb497c2c18e4b4293af4e134f6-CuXVbn_fw658", @"http://img.hb.aicdn.com/d534a50adbf8c0a6a886f28b7cc7148a723be6c42f511-9gvr0u_fw658"]; 91 | NSURL *url = [NSURL URLWithString:imageArray[arc4random() % imageArray.count]]; 92 | 93 | SDWebImageDownloader *downManager = [SDWebImageDownloader sharedDownloader]; 94 | //不管缓存是否存在图片,都重新请求新的图片,删除旧的,保存新的图片 95 | [imageManager cachedImageExistsForURL:url completion:^(BOOL isInCache) { 96 | //删除 97 | [[SDImageCache sharedImageCache] removeImageForKey:adImageName withCompletion:nil]; 98 | }]; 99 | [downManager downloadImageWithURL:url options:SDWebImageDownloaderUseNSURLCache progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) { 100 | //保存 101 | if (image && finished) { 102 | [[SDImageCache sharedImageCache] storeImage:image forKey:adImageName completion:nil]; 103 | } 104 | }]; 105 | } 106 | 107 | - (void)adViewWithData:(NSData *)data { 108 | [self startTimer]; 109 | UIWindow *window = [UIApplication sharedApplication].keyWindow; 110 | [window addSubview:self]; 111 | 112 | _adView.image = [UIImage imageWithData:data]; 113 | _adView.contentMode = UIViewContentModeScaleAspectFill; 114 | } 115 | 116 | ``` 117 | -------------------------------------------------------------------------------- /show1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCBrother/ADPageViewDemo/ad65e2b7cab5fb910dc4d63718179eba0cd9bbdd/show1.gif -------------------------------------------------------------------------------- /show2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCBrother/ADPageViewDemo/ad65e2b7cab5fb910dc4d63718179eba0cd9bbdd/show2.gif --------------------------------------------------------------------------------