I am not receiving any errors for attempting to display the image from a URL, however nothing displays. Do I have to download the image locally before attempting to display it? Excuse my ignorance, I'm a total iOS dev newbie haha.
- (void) viewDidLoad {
NSData *dataBuff = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString:@"https://i1.wp.com/www.penelopeperu.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-22-at-7.24.16-AM-e1503412089169.png"]];
UIImage * imgBuffer = [[UIImage alloc] initWithData:dataBuff];
img = [[UIImageView alloc] initWithImage:imgBuffer];
img.image = randImgBuffer;
}
}
( img
is defined in my header file as a UIImageView
)
Issue in code try this solution
- (void) viewDidLoad {
NSData *dataBuff = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString:@"https://i1.wp.com/www.penelopeperu.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-22-at-7.24.16-AM-e1503412089169.png"]];
UIImage * imgBuffer = [[UIImage alloc] initWithData:dataBuff];
img.image = imgBuffer;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.