当前位置:网站首页>Sdwebimage source code comb 4 # introduce several usages of existing code
Sdwebimage source code comb 4 # introduce several usages of existing code
2022-07-28 23:15:00 【Fluttering moth】
Usage examples :
BJCAImageView As UIImageView An alternative
The most common use is and UITableView Combined use of :
- - stay Interface Builder Lieutenant general UIImageView As UITableViewCell The child views ;
- - In the identification panel , Set the class name to BJCAWebImageView;
- - from bundle Set a picture as a bitmap ;
- - stay tableview:cellForRowAtIndexPath: In the method , Download the pictures url By calling setImageWithURL The method is passed in ,
Everything will be handled , From parallel download to cache management .
Asynchronous Image Downloader
It can be used independently and inherited from NSOperation Image Downloader for . Just create one BJCAWebImageDownloader example , Use its constructor :
downloader = [BJCAWebImageDownloader downloaderWithURL:url target:self action:@selector(downloadFinishedWithImage:)];The download will be queued immediately ,downloadFinishedWithImage: Method will be called after the image download is completed , We need to pay attention to , It may be in a non main thread .
Asynchronous image storage
You can use singular numbers based on NSOperation Image cache storage .BJCAImageCache There is a memory cache and an optional disk cache . Disk cache writes are performed asynchronously , Not to UI Add unnecessary delays .
BJCAImageCache Class for convenience , Created a singleton method , But if you want to have your own cache namespace , You can create instances of this class by yourself .
To find cached images , have access to imageForKey: Method . If you return nil, It means that the cache does not currently own images . therefore , We need to generate and cache it . Cache key key Is the unique identification of the application of the image to be cached . It is usually the absolute of the image URL.
UIImage *cachedImage = [[BJCAImageCache sharedImageCache] imageFromKey:[url absoluteString]];By default , Image not found in cache , Will continue to look in the disk , It can also be used directly -(UIImage *)imageFromKey:(NSString *)key fromDisk:(BOOL)fromDisk; Method .
Store pictures in cache , have access to -(void)storeImage:(UIImage *)image forKey:(NSString *)key; Method .
By default , Images will be stored in memory and asynchronously on disk . If you only want memory cache, you can use -(void)storeImage:(UIImage *)image foeKey:(NSString *)key toDisk:(BOOL)toDisk; Method , take toDisk The parameter is set to NO.
边栏推荐
- TypeError: can‘t convert cuda:0 device type tensor to numpy. Use Tensor. cpu() to copy the tensor to
- Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
- Symbol symbol type
- Yolov5 improvement 5: improve the feature fusion network panet to bifpn
- 【滤波跟踪】基于EKF、时差和频差定位实现目标跟踪附matlab代码
- Record a question about the order of trigonometric function exchange integrals
- c语言进阶篇:指针(二)
- Summary of core functions of software testing tool Fiddler postman JMeter charlse
- 终端输出g_debug()信息
- Target detection notes fast r-cnn
猜你喜欢

【滤波跟踪】基于EKF、时差和频差定位实现目标跟踪附matlab代码

Summary of common formula notes for solving problems in Higher Mathematics

Yolov5 improvement 15: network lightweight method deep separable convolution

《MySQL数据库进阶实战》读后感(SQL 小虚竹)

Hands on Teaching of servlet use (1)

业界首创云原生安全检测双模型!安全狗重磅报告亮相数字中国建设峰会
![[radar] radar signal online sorting based on kernel clustering with matlab code](/img/56/1f8e8690b47fc4a1f101d4e530b87f.png)
[radar] radar signal online sorting based on kernel clustering with matlab code

【C语言】三子棋小游戏实现

Thesis reading (0) - alexnet of classification

The industry's first cloud native security detection dual model! Safety dog heavyweight report appears at the digital China Construction Summit
随机推荐
Summary of core functions of software testing tool Fiddler postman JMeter charlse
6 个超级良心的开源教程!
[mongodb] basic use of mongodb database, special cases, and the installation and creation process of mongoose (including the installation of mongoose fixed version)
Wheel 7: TCP client
Improvement 17 of yolov5: cnn+transformer -- integrating bottleneck transformers
Written questions and answers of software test interview (software test question bank)
In 2020, the top ten domestic IC design enterprises will be exposed! These five industrial challenges still need to be overcome!
美国FCC提供16亿美元资助本国运营商移除华为和中兴设备
Learning experience sharing 3: yolov5 training data set path index
WebView optimization
[physical application] atmospheric absorption loss with matlab code
Invest 50billion yuan! SMIC capital was officially registered!
Morphology of image
Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
Es learning directory
(重要)初识C语言 -- 函数
Cglib create proxy
一份来自奎哥的全新MPLS笔记,考IE必看 ----尚文网络奎哥
【复制】互联网术语、简称、缩写
Kotlin JVM annotation