我有一个UIScrollView,在里面创建了多个UIImageView,如下所示。
问题在于当点击图像时,imageTapped未被调用。
如果我将手势识别器添加到滚动视图中,像这样:
frame = [[UIImageView alloc] initWithImage:bg];
frame.frame = CGRectMake(FRAME_SEPARATOR + numPage*1024 + numColumn*(FRAME_SEPARATOR+230), 10 +numRow*(FRAME_SEPARATOR+145), 230, 145);
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTapped:)];
[frame addGestureRecognizer:tap];
[tap release];
[scroll addSubView:frame];
问题在于当点击图像时,imageTapped未被调用。
如果我将手势识别器添加到滚动视图中,像这样:
UITapGestureRecognizer *tap =
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTapped:)];
[scroll addGestureRecognizer:tap];
[tap release];
触发了imageTapped函数。
如何检测UIImageView上的点击事件?
谢谢。