将图像添加到缩略图库时失败

发布于 2024-08-29 13:33:15 字数 492 浏览 5 评论 0原文

早上好, 我一直在四处浏览,试图找出在尝试将缩略图添加到图库视图时做错了什么,但无法弄清楚它到底是什么。 我正在尝试使用以下代码将缩略图粘贴到空白视图上:

UIImageView *any = [[UIImageView alloc] initWithFrame:CGRectMake(a,b,70,60)];
any.image = [UIImage imageNamed:selectedThumbPath];
any.tag = 0;
[self.view addSubview:any];

在上面的示例中:

a = 165
b = 150
selectedThumbPath = the full path to a thumbnail ie. /users/Cleverbum/library etc

我正在拉头发,没有错误消息,也没有任何线索说明为什么它没有绘制任何内容。更糟糕的是,这是我唯一没有更改的代码部分之一!

morning all,
I've been browsing around trying to work out what I've done wrong when trying to add a thumbnail to a gallery view, but can't work out what on earth it might be.
I'm trying to use the following code to stick a thumbnail onto a blank view:

UIImageView *any = [[UIImageView alloc] initWithFrame:CGRectMake(a,b,70,60)];
any.image = [UIImage imageNamed:selectedThumbPath];
any.tag = 0;
[self.view addSubview:any];

In the above example:

a = 165
b = 150
selectedThumbPath = the full path to a thumbnail ie. /users/Cleverbum/library etc

I'm pulling my hair out, there are no error messages, and no clues as to why it's not drawing anything. What's worse is that this is one of the only parts of the code i've not changed!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心凉 2024-09-05 13:33:15

不久前我遇到了类似的问题。如果我记得的话, imageNamed: 似乎只适用于我的项目中的图像。尝试查看 imageWithContentsOfFile: 并将 NSFile 从该路径传递给它。

I ran into a problem similar to this a while back. If I recall, imageNamed: only seemed to work on images in my project. Try looking into imageWithContentsOfFile: and pass it the NSFile from that path.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文