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

时间:2012-02-16 05:06:24

标签: xcode uiimageview uibutton touch-event

我对目标很陌生,我正在尝试增强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。如果你能指出我正确的方向,我将不胜感激。

1 个答案:

答案 0 :(得分:0)

- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{
    UITouch *touch = [touches anyObject];
    if([touch.view isEqual:imageViewObject])
{
   //maximize the image here
}
}