【发布时间】:2012-12-14 10:42:46
【问题描述】:
我正在开发一个应用程序,我的任务是从我创建滚动视图并将图像放置在滚动条上的数据库中获取 url 链接。
我编写了一些代码,当我单击图像时,我必须在我放置在滚动视图上方的 web 视图中显示 url 页面。
为此,我编写了用于在单击图像时获取 url 的触摸代码,但是我遇到了问题,例如我的单击在图像和滚动视图上也不起作用,但它在图像和滚动视图的下部起作用一个正常的视图。你可以在下面找到我的触摸码
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch * touch = [[event allTouches] anyObject];
for(int index=0;index<[array count];index++)
{
UIImageView *imgView = [array objectAtIndex:index];
if(CGRectContainsPoint([imgView frame], [touch locationInView:scrollView]))
{
NSString *strgetcontenturl = [[NSString alloc]initWithString:[arrayvideoFile objectAtIndex:index]];
NSURL *url = [NSURL URLWithString:strgetcontenturl];
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:strgetcontenturl]]];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webview loadRequest:requestObj];
}}}
这里 array 是我存储所有图像的地方,而 arrayvideoFile 是我存储所有 url 的地方。
请帮忙。
【问题讨论】:
-
你是如何在滚动视图上添加图片的?
标签: iphone objective-c ios ios5 uiscrollview