用于显示 sqlite 表中图像的 NSURL 代码
我正在使用此 NSURL 代码来显示图像。我想要做的是插入数据库表中的 url 来代替下面代码中显示的静态 url:
有谁知道我应该如何进行?
NSURL *url = [NSURL URLWithString:@"http://www.nyapplecountry.com/images/photosvarieties/redrome04.jpg"];
UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
[self.view addSubview:[[UIImageView alloc] initWithImage:image]];
[self.containerView addSubview:self.mainView];
我在想类似的事情:
NSString *urlAddress = [NSString stringWithFormat:@"%@", place.url];
其中 place.url
来自我的数据库表。但我错过了一些东西,不确定是什么。
感谢您的帮助
Ii'm using this NSURL code to display an image. what I want to do is to insert a url from my database table in place of the static url shown in the code below:
Does anyone know how I should proceed?
NSURL *url = [NSURL URLWithString:@"http://www.nyapplecountry.com/images/photosvarieties/redrome04.jpg"];
UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
[self.view addSubview:[[UIImageView alloc] initWithImage:image]];
[self.containerView addSubview:self.mainView];
I was thinking of something like:
NSString *urlAddress = [NSString stringWithFormat:@"%@", place.url];
where place.url
is coming from my db table. I'm missing something though, not sure what.
thanks for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
place.url
是一个NSString 对象
以及图像的完整 URL 吗?那么事情就会很简单Is
place.url
aNSString object
and the full URL to the image? Then it would be as simple as你不能那样做。您必须从数据库读取图像并使用该数据初始化 UIImage。
You can't do it that way. You have to read image from data base and initialize UIImage with that data.