Skip to content

Commit 5746fed

Browse files
committed
修改了SDWebImage对gif图像的解析-把它从pod里面拿出来了,囧
1 parent 171d1ba commit 5746fed

63 files changed

Lines changed: 4621 additions & 75 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 110 additions & 0 deletions
Large diffs are not rendered by default.

Coding_iOS/Coding_iOS-Prefix.pch

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#import <BlocksKit/BlocksKit+UIKit.h>
3737
#import <ReactiveCocoa/ReactiveCocoa.h>
3838
#import <ReactiveCocoa/RACEXTScope.h>
39+
#import "UIImageView+WebCache.h"
3940

4041
#endif
4142
//友盟统计

Coding_iOS/Controllers/Login/LoginViewController.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#import <NYXImagesKit/NYXImagesKit.h>
1616
#import <UIImage+BlurredFrame/UIImage+BlurredFrame.h>
1717
#import <Masonry/Masonry.h>
18-
#import <SDWebImage/UIImageView+WebCache.h>
1918

2019

2120
@interface LoginViewController ()

Coding_iOS/Controllers/MeSetting/UserInfoViewController.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#import "UserInfoViewController.h"
1414
#import "Coding_NetAPIManager.h"
15-
#import <SDWebImage/UIImageView+WebCache.h>
1615
#import "TitleValueCell.h"
1716
#import "UITapImageView.h"
1817
#import "UsersViewController.h"

Coding_iOS/Controllers/RootControllers/Me_RootViewController.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#import "Coding_NetAPIManager.h"
1414
#import "RDVTabBarController.h"
1515
#import "RDVTabBarItem.h"
16-
#import <SDWebImage/UIImageView+WebCache.h>
1716
#import "TitleValueCell.h"
1817
#import "SettingViewController.h"
1918
#import "UsersViewController.h"

Coding_iOS/Controllers/RootControllers/Project_RootViewController.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#import "Project_RootViewController.h"
1010
#import "Coding_NetAPIManager.h"
1111
#import "LoginViewController.h"
12-
#import <SDWebImage/UIImageView+WebCache.h>
1312
#import "ProjectListView.h"
1413
#import "ProjectViewController.h"
1514
#import "HtmlMedia.h"

Coding_iOS/Util/Common/UITapImageView.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//
88

99
#import "UITapImageView.h"
10-
#import <SDWebImage/UIImageView+WebCache.h>
1110

1211
@interface UITapImageView ()
1312

Coding_iOS/Vendor/MJPhotoBrowser/MJPhotoBrowser.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ - (void)viewDidLoad
6464
[self createToolbar];
6565
}
6666

67+
- (void)didReceiveMemoryWarning {
68+
[super didReceiveMemoryWarning];
69+
// Dispose of any resources that can be recreated.
70+
[self photoViewSingleTap:nil];
71+
[self photoViewDidEndZoom:nil];
72+
self.view = nil;
73+
}
74+
6775
- (void)show
6876
{
6977
UIWindow *window = [UIApplication sharedApplication].keyWindow;

Coding_iOS/Vendor/MJPhotoBrowser/MJPhotoView.m

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
#import "MJPhotoView.h"
99
#import "MJPhoto.h"
1010
#import "MJPhotoLoadingView.h"
11-
#import <SDWebImage/UIImageView+WebCache.h>
1211
#import <QuartzCore/QuartzCore.h>
12+
#import <YLGIFImage/YLGIFImage.h>
13+
#import <YLGIFImage/YLImageView.h>
1314

1415
@interface MJPhotoView ()
1516
{
1617
BOOL _doubleTap;
17-
UIImageView *_imageView;
18+
YLImageView *_imageView;
1819
MJPhotoLoadingView *_photoLoadingView;
1920
}
2021
@end
@@ -26,7 +27,7 @@ - (id)initWithFrame:(CGRect)frame
2627
if ((self = [super initWithFrame:frame])) {
2728
self.clipsToBounds = YES;
2829
// 图片
29-
_imageView = [[UIImageView alloc] init];
30+
_imageView = [[YLImageView alloc] init];
3031
_imageView.contentMode = UIViewContentModeScaleAspectFit;
3132
[self addSubview:_imageView];
3233

@@ -54,6 +55,12 @@ - (id)initWithFrame:(CGRect)frame
5455
return self;
5556
}
5657

58+
//设置imageView的图片
59+
- (void)configImageViewWithImage:(UIImage *)image{
60+
_imageView.image = image;
61+
}
62+
63+
5764
#pragma mark - photoSetter
5865
- (void)setPhoto:(MJPhoto *)photo {
5966
_photo = photo;
@@ -65,29 +72,33 @@ - (void)setPhoto:(MJPhoto *)photo {
6572
- (void)showImage
6673
{
6774
if (_photo.firstShow) { // 首次显示
68-
_imageView.image = _photo.placeholder; // 占位图片
69-
75+
_imageView.image = _photo.placeholder;
7076
if (_photo.image) {
77+
_imageView.image = _photo.image;
7178
if ([self.photoViewDelegate respondsToSelector:@selector(photoViewImageFinishLoad:)]) {
7279
[self.photoViewDelegate photoViewImageFinishLoad:self];
7380
}
74-
// 调整frame参数
75-
[self adjustFrame];
76-
}else if (![_photo.url.absoluteString hasSuffix:@"gif"]) {
77-
// 不是gif,就马上开始下载
81+
}else {
82+
// 显示进度条
83+
[_photoLoadingView showLoading];
84+
[self addSubview:_photoLoadingView];
85+
7886
ESWeakSelf;
79-
ESWeak_(_photo);
80-
[_imageView sd_setImageWithURL:_photo.url placeholderImage:_photo.placeholder options:SDWebImageRetryFailed|SDWebImageLowPriority completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
87+
ESWeak_(_photoLoadingView);
88+
ESWeak_(_imageView);
89+
90+
[SDWebImageManager.sharedManager downloadImageWithURL:_photo.url options:SDWebImageRetryFailed|SDWebImageLowPriority progress:^(NSInteger receivedSize, NSInteger expectedSize) {
91+
ESStrong_(_photoLoadingView);
92+
if (receivedSize > kMinProgress) {
93+
__photoLoadingView.progress = (float)receivedSize/expectedSize;
94+
}
95+
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
8196
ESStrongSelf;
82-
ESStrong_(_photo);
97+
ESStrong_(_imageView)
8398
if (image) {
84-
__photo.image = image;
99+
__imageView.image = image;
85100
}
86-
if ([_self.photoViewDelegate respondsToSelector:@selector(photoViewImageFinishLoad:)]) {
87-
[_self.photoViewDelegate photoViewImageFinishLoad:_self];
88-
}
89-
// 调整frame参数
90-
[_self adjustFrame];
101+
[_self photoDidFinishLoadWithImage:image];
91102
}];
92103
}
93104
} else {
@@ -102,23 +113,28 @@ - (void)showImage
102113
- (void)photoStartLoad
103114
{
104115
if (_photo.image) {
105-
self.scrollEnabled = YES;
106116
_imageView.image = _photo.image;
117+
self.scrollEnabled = YES;
107118
} else {
119+
_imageView.image = _photo.placeholder;
108120
self.scrollEnabled = NO;
109121
// 直接显示进度条
110122
[_photoLoadingView showLoading];
111123
[self addSubview:_photoLoadingView];
112124

113125
ESWeakSelf;
114126
ESWeak_(_photoLoadingView);
115-
[_imageView sd_setImageWithURL:_photo.url placeholderImage:_photo.srcImageView.image options:SDWebImageRetryFailed|SDWebImageLowPriority progress:^(NSInteger receivedSize, NSInteger expectedSize) {
127+
ESWeak_(_imageView);
128+
129+
[SDWebImageManager.sharedManager downloadImageWithURL:_photo.url options:SDWebImageRetryFailed|SDWebImageLowPriority progress:^(NSInteger receivedSize, NSInteger expectedSize) {
116130
ESStrong_(_photoLoadingView);
117131
if (receivedSize > kMinProgress) {
118132
__photoLoadingView.progress = (float)receivedSize/expectedSize;
119133
}
120-
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
134+
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
121135
ESStrongSelf;
136+
ESStrong_(_imageView);
137+
__imageView.image = image;
122138
[_self photoDidFinishLoadWithImage:image];
123139
}];
124140
}
@@ -201,44 +217,22 @@ - (void)hide
201217
[_photoLoadingView removeFromSuperview];
202218
self.contentOffset = CGPointZero;
203219

204-
// 清空底部的小图
205-
// _photo.srcImageView.image = nil;
206-
207220
CGFloat duration = 0.3;
208-
if (_photo.srcImageView.clipsToBounds) {
209-
[self performSelector:@selector(reset) withObject:nil afterDelay:duration];
210-
}
211221
self.superview.backgroundColor = [UIColor clearColor];
212222
[UIView animateWithDuration:duration + 0.1 animations:^{
213223
self.alpha = 0.0;
214-
// _imageView.frame = [_photo.srcImageView convertRect:_photo.srcImageView.bounds toView:nil];
215-
//
216-
// // gif图片仅显示第0张
217-
// if (_imageView.image.images) {
218-
// _imageView.image = _imageView.image.images[0];
219-
// }
220-
221224
// 通知代理
222225
if ([self.photoViewDelegate respondsToSelector:@selector(photoViewSingleTap:)]) {
223226
[self.photoViewDelegate photoViewSingleTap:self];
224227
}
225228
} completion:^(BOOL finished) {
226-
// 设置底部的小图片
227-
// _photo.srcImageView.image = _photo.placeholder;
228-
229229
// 通知代理
230230
if ([self.photoViewDelegate respondsToSelector:@selector(photoViewDidEndZoom:)]) {
231231
[self.photoViewDelegate photoViewDidEndZoom:self];
232232
}
233233
}];
234234
}
235235

236-
- (void)reset
237-
{
238-
// _imageView.image = _photo.capture;
239-
// _imageView.contentMode = UIViewContentModeScaleToFill;
240-
}
241-
242236
- (void)handleDoubleTap:(UITapGestureRecognizer *)tap {
243237
_doubleTap = YES;
244238

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2009 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+

0 commit comments

Comments
 (0)