【发布时间】:2012-02-27 03:31:48
【问题描述】:
我正在尝试使用 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];
【问题讨论】:
-
你的图片在 UITableViewCells 中吗?您是否在
cellForRowAtIndexPath:委托方法中调用setImageWithURL? -
是的,你的两个问题。
-
能否在
tableView:cellForRowAtIndexPath:中包含用于设置远程图像的代码? -
Mattt,包含该代码。它在我的帖子的顶部。
标签: ios ios5 uiimageview afnetworking