以下に示すように、AFNetworking UIImageView 呼び出しを使用して URL から画像をロードしようとしています。
[self.image setImageWithURL:[NSURL URLWithString:feed.imageURL] placeholderImage: [UIImage imageNamed:@"logo"]];
プレースホルダー画像は常に表示されますが、「feed.imageURL」からの実際の画像は表示されません。URL が実際に正しいことを確認しました。確認するためにハードコーディングしましたが、それでも何もありません。
私の基本的なアプリのセットアップはタブ コントローラーです...そして、viewDidLoad で、HTTP 要求を実行して JSON データを収集するメソッド「fetchFeed」を呼び出します。
私のリクエストブロックは次のようになります:
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];