如何使用小(缩略图大小)图像作为按钮 - 加载全屏图像?或者触摸事件?

发布于 2025-01-05 21:41:00 字数 592 浏览 6 评论 0原文

我对 Objective 还很陌生,我正在尝试增强 iPhone 应用程序(由其他人完成的编码)。我正在尝试从互联网上提取图像并将其显示为缩略图(就像在 iPhone 通讯录应用程序中一样)。

我想让用户触摸小图像,它就会变成全尺寸图像。我在一些教程上看到了触摸事件,但我不知道为什么它对我不起作用。

这是在我的 .m 文件中,用于从某个网站提取图像:

- (void) viewDidLoad {

    urlImage.image = [UIImage imageWithData: [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Koala_with_young.ogv/seek%3D3.5-Koala_with_young.ogv.jpg"]]];
}

除此之外,我不确定如何将 url 中的图像与触摸事件一起使用,遗憾的是所有教程大多都是关于静态图像的。

我尝试创建 UIView 的子类,但无法将图像连接到 IBOutlet。如果您能指出正确的方向,我将不胜感激。

I'm pretty new to objective and I'm trying to enhance an iPhone app (coding done by someone else). I'm trying to pull an image from the internet and its displayed as a thumbnail (like in the iphone address book app).

I would like to have the user touch the small image and it changes to a full sized image. I've seen touch events on some tutorials but I have no idea why it's not working for me.

This is in my .m file to pull the image from some website:

- (void) viewDidLoad {

    urlImage.image = [UIImage imageWithData: [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Koala_with_young.ogv/seek%3D3.5-Koala_with_young.ogv.jpg"]]];
}

Other than that I am uncertain how to use an image from url with the touch event, sadly all the tutorials are mostly about a static image.

I tried to create a subclass of UIView but I couldn't connect the image to the IBOutlet. I would appreciate it if you could point me in the right direction.

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

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

发布评论

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

评论(1

何处潇湘 2025-01-12 21:41:00
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{
    UITouch *touch = [touches anyObject];
    if([touch.view isEqual:imageViewObject])
{
   //maximize the image here
}
}
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{
    UITouch *touch = [touches anyObject];
    if([touch.view isEqual:imageViewObject])
{
   //maximize the image here
}
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文