【发布时间】:2014-01-05 08:09:45
【问题描述】:
我无法通过点击手势创建 ImageView 列表。当我创建手势时,不会调用选择器函数。当我创建只有一个 imageView 函数被调用。知道为什么吗?都是大滚动视图的子视图。
这是我的代码:
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTaped:)];
singleTap.numberOfTapsRequired = 1;
singleTap.numberOfTouchesRequired = 1;
for(int k=0;k<MyList.count;k++){
for(int i=0;i<listSize;i++){
UIImageView *clickForDetail =[[UIImageView alloc]initWithFrame:CGRectMake(i*HELLO_WIDTH,k*LIST_ROW_HEIGH ,HELLO_WIDTH, LIST_ROW_HEIGH)];
clickForDetail.backgroundColor = [UIColor clearColor];
clickForDetail.tag = tag;
clickForDetail.userInteractionEnabled = YES;
[clickForDetail addGestureRecognizer:singleTap];
[myScroll addSubview:clickForDetail];
tag++;
}
}
和选择器功能:
-(void)imageTaped: (UITapGestureRecognizer *)recognizer
{
NSLog(@"single Tap on imageview");
}
是否有可能以某种方式获取被点击的 ImageView 的标签?
【问题讨论】:
标签: ios objective-c uitableview memory uiscrollview