如果同时给一个button 设置两个状态的网络图片 如下:
[button setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/images/%@.png", URL_ROOT, NORMAL_STATE]] forState:UIControlStateNormal]; [button setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/images/%@.png", URL_ROOT, SELECTED_STATE]] forState:UIControlStateSelected];那么设置第二张图片时,如果第一张还没下载完,会自动取消第一张的下载。造成第一张图片显示不出来。
当然这是sdWebImage的一个小bug,我临时的处理方案如下:
[button setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/images/%@.png", URL_ROOT, NORMAL_STATE]] forState:UIControlStateNormal completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) { [button setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/images/%@.png", URL_ROOT, SELECTED_STATE]] forState:UIControlStateSelected]; }];
SDWebImage [UIButton setImageWithURL:(NSURL *) forState:(UIControlState)] 的bug,布布扣,bubuko.com
SDWebImage [UIButton setImageWithURL:(NSURL *) forState:(UIControlState)] 的bug