AFNetworking 2.0 中的 setImageWithURL
setImageWithURL in AFNetworking 2.0
在AFNetworking 1.x
中,我们可以这样使用setImageWithURL
:
NSURL* imageURL = [api urlForImageWithId:IdPhoto isThumb:NO];
[photoView setImageWithURL: imageURL];
}
其中 IdPhoto
是我要加载到图像视图中的照片的 ID。
此代码在 AFNetworking 2.0
中无效。我想我必须以某种方式使用 AFImageResponseSerializer
,但无法弄清楚如何编写代码。
谢谢
要使此代码有效,您需要导入 <UIImageView+AFNetworking.h>
在AFNetworking 1.x
中,我们可以这样使用setImageWithURL
:
NSURL* imageURL = [api urlForImageWithId:IdPhoto isThumb:NO];
[photoView setImageWithURL: imageURL];
}
其中 IdPhoto
是我要加载到图像视图中的照片的 ID。
此代码在 AFNetworking 2.0
中无效。我想我必须以某种方式使用 AFImageResponseSerializer
,但无法弄清楚如何编写代码。
谢谢
要使此代码有效,您需要导入 <UIImageView+AFNetworking.h>