-
Notifications
You must be signed in to change notification settings - Fork 1
/
TCWebImageView.h
69 lines (45 loc) · 2.28 KB
/
TCWebImageView.h
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// TCImageView.h
// TCImageViewDemo
//
#import <Foundation/Foundation.h>
#define CACHED_IMAGE_JPEG_QUALITY 1.0
#define DOWNLOAD_PROGRESS_INCREMENT_KB 25
@class TCWebImageView;
// Block Typedefs
typedef void (^TCWebImageViewFinishedLoading)(UIImage *image, BOOL fromCache);
typedef void (^TCWebImageViewDidFailLoading)(NSError *error);
typedef void (^TCWebImageViewLoadingProcess)(long long totalBytes, long long bytesDownloaded);
// Delegate methods (if using a delegate)
@protocol TCImageViewDelegate <NSObject>
@optional
-(void)webImageView:(TCWebImageView *)view willUpdateImage:(UIImage *)image;
-(void)webImageView:(TCWebImageView *)view didFinishLoadingImage:(UIImage *)image fromCache:(BOOL)fromCache;
-(void)webImageView:(TCWebImageView *)view failedWithError:(NSError *)error;
-(void)webImageView:(TCWebImageView *)view loadedBytes:(long long)loadedBytes totalBytes:(long long)totalBytes;
@end
@interface TCWebImageView : UIImageView
// Public Properties
@property NSURL* url;
@property UIView* placeholder;
@property (getter = isCaching) BOOL caching;
@property NSTimeInterval cacheTime;
@property (readonly) NSNumber *loadingProgress;
// Blcoks are also properties, use them before calling -loadImage method
@property (readwrite, copy) TCWebImageViewFinishedLoading finishedLoadingBlock;
@property (readwrite, copy) TCWebImageViewDidFailLoading failedLoadingBlock;
@property (readwrite, copy) TCWebImageViewLoadingProcess loadingProcessBlock;
@property id<TCImageViewDelegate> delegate;
+ (void)resetGlobalCache; // This will remove all cached images managed by any TCWebImageView instatces
+ (NSString*)cacheDirectoryAddress;
// Use those with delegates or set callback block properties before calling -loadImage method
- (id)initWithURL:(NSURL *)url placeholderView:(UIView *)placeholderView;
- (id)initWithURL:(NSURL *)url placeholderImage:(UIImage *)image;
// Inline block callbacks, no delegates requered when using this init
- (id)initWithURL:(NSURL *)url placeholderImage:(UIImage *)image completed:(TCWebImageViewFinishedLoading)complete failed:(TCWebImageViewDidFailLoading)failed loadingProcess:(TCWebImageViewLoadingProcess)loading;
- (void)loadImage;
- (void)cancelLoad;
- (void)reloadWithURL:(NSURL *)url;
- (NSString*)cachedImageSystemName;
- (void)resetCache;
@end