【发布时间】:2018-11-25 09:19:42
【问题描述】:
尝试显示来自 URL 的图像时,我没有收到任何错误,但没有显示任何内容。在尝试显示之前,我是否必须在本地下载图像?原谅我的无知,我是一个iOS开发新手哈哈。
- (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 在我的头文件中定义为UIImageView)
【问题讨论】:
标签: ios objective-c uiimageview uiimage uikit