gpt4 book ai didi

ios - 如何知道 AfNetworking 是否下载了所有图像

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:06:29 25 4
gpt4 key购买 nike

我想我问的是一个愚蠢的问题,但只是好奇。有什么方法可以知道是否所有图像都已下载。我这样做的动机是,我想在下载完所有图像后调用一个函数。

我在 for 循环中使用 UIImageview setImageWithURL

提前致谢:)

最佳答案

您需要使用 UIImageView+AFNetworking 的 setImageWithURLRequest 方法。成功 block 在图像加载完成时执行。

 @param urlRequest The URL request used for the image request.
@param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
@param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the request and response parameters will be `nil`.
@param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
*/
- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
placeholderImage:(UIImage *)placeholderImage
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure;

关于ios - 如何知道 AfNetworking 是否下载了所有图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21834169/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com