This is from the UIImageView+AFNetworking
library.
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;
}
I added in setNeedsLayout
and setNeedsDisplay
. The imageview, a UITableViewCell
's imageView in this case, still has a 0,0,0,0
frame. Clicking on the cell will refresh the imageview but otherwise the image does not show up.
How do I force the UIImageView
to resize?
I tried putting in
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];
based on
How to make UIImageView automatically resize to the size of the image loaded
's solution of setting the frame. I can log out a bigger frame there but it does not show up on screen.