我在 UIWindow 上使用 UIimageview。我想处理该 Imageview 的触摸事件,但我无法做到。
当我在 UIview 上使用 UIimageView 时,我们可以使用 touchBegan、touchEnded 但是当它在 UIWindow 而不是 UIView 上时如何处理它。
谢谢..
我在 UIWindow 上使用 UIimageview。我想处理该 Imageview 的触摸事件,但我无法做到。
当我在 UIview 上使用 UIimageView 时,我们可以使用 touchBegan、touchEnded 但是当它在 UIWindow 而不是 UIView 上时如何处理它。
谢谢..
如果你只想处理水龙头,你必须设置,
imageView.userInteractionEnabled = YES;
默认情况下UIImageView的userInteractionEnabled属性设置为NO。你可以给它添加一个点击手势识别器,
UITapGestureRecognizer *tgr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(anyMethod)];
[imageView addGestureRecognizer:tgr];
[tgr release];
如果要移动图像,可以使用UIPanGestureRecognizer。
- (void)sendEvent:(UIEvent *)event
试试这个功能