これはUIImageView+AFNetworking
ライブラリからです。AFNetworkingはUITableViewCellのimageViewイメージをURLで設定すると、イメージビューフレームはまだイメージ設定後も0です
AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
if ([[urlRequest URL] isEqual:[[self.af_imageRequestOperation request] URL]]) {
if (success) {
success(operation.request, operation.response, responseObject);
} else {
self.image = responseObject;
[self setNeedsLayout];
[self setNeedsDisplay];
}
self.af_imageRequestOperation = nil;
}
私はsetNeedsLayout
とsetNeedsDisplay
に追加。この場合の画像ビューUITableViewCell
のimageViewにはまだ0,0,0,0
のフレームがあります。セルをクリックするとイメージビューが更新されますが、イメージが表示されません。
UIImageView
のサイズを変更するにはどうすればよいですか?
Iフレームの設定
How to make UIImageView automatically resize to the size of the image loaded
の溶液に基づく
self.image = responseObject;
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y,
self.image.size.width, self.image.size.height);
[self setNeedsDisplay];
[self setNeedsLayout];
に入れてみました。私はそこに大きなフレームをログアウトすることができますが、それは画面に表示されません。