在UIwindow上的UIimageView上触摸事件
问题描述:
在UIWindow上面使用UIimageView。我想要处理该Imageview的触摸事件,但无法做到这一点。在UIwindow上的UIimageView上触摸事件
当我在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
试试这个功能