我正在尝试使用 AFNetworking UIImageView 调用从 URL 加载图像,如下所示:
[self.image setImageWithURL:[NSURL URLWithString:feed.imageURL] placeholderImage: [UIImage imageNamed:@"logo"]];
占位符图像始终显示,但来自“feed.imageURL”的实际图像永远不会出现。我已验证该 URL 实际上是正确的。我什至硬编码它以确保,但仍然没有。
我的基本应用程序设置是一个选项卡控制器……在 viewDidLoad 中,我调用了一个方法“fetchFeed”,它执行 HTTP 请求以收集我的 JSON 数据。
我的请求块看起来像:
AFJSONRequestOperation *operation = [AFJSONRequestOperation
JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
[self parseDictionary:JSON];
isLoading = NO;
[self.tableView reloadData];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
NSLog(@"Error: %@", error);
[self showNetworkError];
isLoading = NO;
[self.tableView reloadData];
}];
operation.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/html", nil];
[queue addOperation:operation];