1

我使用 UIScrollView 来显示一系列UIImageViewUIImageView添加为子视图scrollview),问题是我已经重写了方法UIImageView

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

但是当我点击图片时,该方法没有被调用,似乎图片没有收到点击事件。确切的原因是什么?我怎样才能解决这个问题?(我已经启用了 UIImageView 的 ExclusiveTouch 和所有视图的 User Interavtion)

4

3 回答 3

2

将 UIImageView 的exclusiveTouchuserInteractionEnabled属性设置为并重YES试。我发现滚动视图的子视图只接收一些事件或不接收事件,并且设置 ExclusiveTouch 允许视图立即声明它们。

于 2012-05-09T03:07:43.520 回答
1

set

imageView.userInteractionEnabled = YES;

and if you just want a tap event for the imageview

just use the UITapGestureRecognizer

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
[imageView addGestureRecognizer:tap];

then you must implement the method

- (void) tap:(UITapGestureRecognizer*)gesture
{
    UIImageView *v = gesture.view;// that your ImageView tapped
}
于 2012-05-09T03:10:16.657 回答
0

imageView.userInteractionEnabled = 否;

于 2012-07-31T10:55:01.520 回答