问题
I am wondering how I can display the images into a table uploaded by a certain device like an "Upload History" option. I have the request retrieving the images as such...
NSString *post = [NSString stringWithFormat:@"device_code=%@", deviceCode];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://www.urlExample.php"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
I am retrieving the images fine I just need help putting them into the table. Anyone have an idea on how I could do that?
回答1:
You just need to render image into your custom cell using URL. You can use SDWebImage to download and stored image into cache memory.
Code to load image into your imageView:
#import <SDWebImage/SDWebImage.h>
[YOUR_IMAGE_VIEW sd_setImageWithURL:[NSURL URLWithString:YOUR_IMAGE_URL]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
来源:https://stackoverflow.com/questions/55641016/displaying-images-in-table-using-http-post-request