CoderZhuXH / Xhwebimageautosize
Licence: mit
网络图片尺寸、高度自适应/适配 - 支持异步缓存imageSize , 支持动态刷新界面
Stars: ✭ 245
Labels
Projects that are alternatives of or similar to Xhwebimageautosize
Php K8s
PHP K8s is a PHP handler for the Kubernetes Cluster API, helping you handling the individual Kubernetes resources directly from PHP, like viewing, creating, updating or deleting resources.
Stars: ✭ 111 (-54.69%)
Mutual labels: pod
Filebeat Kubernetes
Filebeat container, alternative to fluentd used to ship kubernetes cluster and pod logs
Stars: ✭ 147 (-40%)
Mutual labels: pod
Modernavplayer
ModernAVPlayer is a persistence AVPlayer wrapper
Stars: ✭ 179 (-26.94%)
Mutual labels: pod
K8s
Deploying Kubernetes High Availability Cluster with Ansible Playbook
Stars: ✭ 125 (-48.98%)
Mutual labels: pod
Uiimage Imagecompress
An iOS library to compress images and optimize uploads
Stars: ✭ 155 (-36.73%)
Mutual labels: pod
Nim ios uikit
网易云信 iOS UI 组件,提供聊天界面,文本消息,图片消息,语音消息,视频消息,地理位置消息,自定义消息(阅后即焚)等消息示例。#推荐客户得比特币,首次推荐得0.02BTC,连续推荐得0.03BTC/单,上不封顶。点击参与https://yunxin.163.com/promotion/recommend
Stars: ✭ 1,326 (+441.22%)
Mutual labels: pod
Iosdebugdatabase
make it easy to debug databases in iOS applications iOS debug database
Stars: ✭ 219 (-10.61%)
Mutual labels: pod
Xhnetworkcache
一行代码将网络数据持久化 - 支持数据同步/异步写入及更新、缓存数据读取、获取缓存数据大小、缓存数据清除.
Stars: ✭ 178 (-27.35%)
Mutual labels: pod
Luexpandabletableview
A subclass of UITableView with expandable and collapsible sections
Stars: ✭ 125 (-48.98%)
Mutual labels: pod
Abexpandableview
Expandable, collapsible, filterable and single/multi selectable table view.
Stars: ✭ 138 (-43.67%)
Mutual labels: pod
Zztools
包括: StarView星星评价(支持半星, 整星, 任意星, 支持拖动, 支持自定义星星图片, 数量, 大小, 间距, 最低分值). 瀑布流(垂直, 浮动, 混合模式瀑布流)等.
Stars: ✭ 175 (-28.57%)
Mutual labels: pod
Fcipaddressgeocoder
iOS Geocoder for geocode device IP Address location using GeoIP service(s) and a block-based syntax. 💻🌍
Stars: ✭ 114 (-53.47%)
Mutual labels: pod
Rnloadingbutton Swift
An easy-to-use UIButton subclass with an activity indicator
Stars: ✭ 181 (-26.12%)
Mutual labels: pod
Fcuuid
iOS UUID / Universally Unique Identifiers library as alternative to UDID and identifierForVendor. 📱
Stars: ✭ 1,387 (+466.12%)
Mutual labels: pod
Kubetail
Bash script to tail Kubernetes logs from multiple pods at the same time
Stars: ✭ 2,468 (+907.35%)
Mutual labels: pod
XHWebImageAutoSize
网络图片尺寸/高度自适应解决方案
==============
前言:
- 1.iOS开发中,常碰到网络图片需要做尺寸适配(使显示出来的图片不变形)
- 2.最好的解决方案是:后台把图片的分辨率拼接在图片的URL地址中,我们截取获得分辨率,从而根据宽高比,来适配imageView尺寸.
- 3.但往往有些时候由于各种原因,图片分辨率后台那边加不上去,没办法只好我们自己来解决了.
- 4.XHWebImageAutoSize就是解决3中的这种情况.
特性:
- 1.异步缓存网络图片尺寸,优先从缓存中获取图片尺寸.
- 2.UITableView,UICollectionView UI动态更新.
技术交流群(群号:537476189).
效果
使用方法
1.此处以在UITableView中使用,UITableViewCell上仅有一个UIImageView为例(其他示例详见DEMO)
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *url = self.dataArray[indexPath.row];
/**
* 参数1:图片URL
* 参数2:imageView 宽度
* 参数3:预估高度(此高度仅在图片尚未加载出来前起作用,不影响真实高度)
*/
return [XHWebImageAutoSize imageHeightForURL:[NSURL URLWithString:url] layoutWidth:[UIScreen mainScreen].bounds.size.width-16 estimateHeight:200];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
DemoVC1Cell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
if(!cell){
cell = [[DemoVC1Cell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
}
NSString *url = self.dataArray[indexPath.row];
//加载网络图片使用SDWebImage
[cell.imgView sd_setImageWithURL:[NSURL URLWithString:url] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
/** 缓存image size */
[XHWebImageAutoSize storeImageSize:image forURL:imageURL completed:^(BOOL result) {
/** reload */
if(result) [tableView xh_reloadDataForURL:imageURL];
}];
}];
return cell;
}
API
- 1.获取图片高度/尺寸及缓存相关
/**
* Get image height
*
* @param url imageURL
* @param layoutWidth layoutWidth
* @param estimateHeight estimateHeight(default 100)
*
* @return imageHeight
*/
+(CGFloat)imageHeightForURL:(NSURL *)url layoutWidth:(CGFloat)layoutWidth estimateHeight:(CGFloat )estimateHeight;
/**
* Get image width
*
* @param url imageURL
* @param layoutHeight layoutHeight
* @param estimateWidth estimateWidth(default 90)
*
* @return imageHeight
*/
+(CGFloat)imageWidthForURL:(NSURL *)url layoutHeight:(CGFloat)layoutHeight estimateWidth:(CGFloat )estimateWidth;
/**
* Get image size from cache,query the disk cache synchronously after checking the memory cache
*
* @param url imageURL
*
* @return imageSize
*/
+(CGSize )imageSizeFromCacheForURL:(NSURL *)url;
/**
* Store an imageSize into memory and disk cache
*
* @param image image
* @param url imageURL
* @param completedBlock An block that should be executed after the imageSize has been saved (optional)
*/
+(void)storeImageSize:(UIImage *)image forURL:(NSURL *)url completed:(XHWebImageAutoSizeCacheCompletionBlock)completedBlock;
- 2.tableView reload
/**
Reload tableView
@param url imageURL
*/
-(void)xh_reloadDataForURL:(NSURL *)url;
- 3.collectionView reload
/**
Reload collectionView
@param url imageURL
*/
-(void)xh_reloadDataForURL:(NSURL *)url;
安装
- 1.将 XHWebImageAutoSize 文件夹添加到工程目录中
- 2.导入 XHWebImageAutoSize.h
- 1.在 Podfile 中添加 pod 'XHWebImageAutoSize'
- 2.执行 pod install 或 pod update
- 3.导入 XHWebImageAutoSize.h
Tips
- 1.如果发现pod search XHWebImageAutoSize 搜索出来的不是最新版本,需要在终端执行cd ~/desktop退回到desktop,然后执行pod setup命令更新本地spec缓存(需要几分钟),然后再搜索就可以了
- 2.如果你发现你执行pod install后,导入的不是最新版本,请删除Podfile.lock文件,在执行一次 pod install
- 3.如果在使用过程中遇到BUG,希望你能Issues我,谢谢(或者尝试下载最新的代码看看BUG修复没有)
系统要求
- 该项目最低支持 iOS 7.0 和 Xcode 7.0
许可证
XHWebImageAutoSize 使用 MIT 许可证,详情见 LICENSE 文件
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].