如何加载带有图像的URL

时间:2011-04-20 15:28:51

标签: iphone objective-c image url

我试图找到当用户点击我的图片(在UIImageView中)时如何加载网页。 例: 如果用户点击徽标google,该应用程序将继续www.google.fr。

谢谢:)

1 个答案:

答案 0 :(得分:1)

首先,您需要对ImageView上的“点按”手势作出反应。

在iOS 3.2及更高版本中,UITapGestureRecognizer非常容易实现:

UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapFrom:)];
[self.imageView addGestureRecognizer:recognizer];
recognizer.delegate = self;
[recognizer release];

..然后,在点击处理程序中,您可以打开您的网址:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.stackoverflow.com"]];

参考文献:

UITapGestureRecognizer Class Reference

UIApplication Class Reference / openURL

相关问题