【发布时间】:2011-07-09 04:29:51
【问题描述】:
我在 UIWindow 上使用 UIimageview。我想处理那个 Imageview 的触摸事件,但是我做不到。
当我在 UIview 上使用 UIimageView 时,我们可以使用 touchBegan、touchEnded 但是当它在 UIWindow 而不是 UIView 上时如何处理它。
谢谢..
【问题讨论】:
标签: iphone objective-c ios uitouch uiwindow
我在 UIWindow 上使用 UIimageview。我想处理那个 Imageview 的触摸事件,但是我做不到。
当我在 UIview 上使用 UIimageView 时,我们可以使用 touchBegan、touchEnded 但是当它在 UIWindow 而不是 UIView 上时如何处理它。
谢谢..
【问题讨论】:
标签: iphone objective-c ios uitouch uiwindow
如果你只想处理水龙头,你必须设置,
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
试试这个功能
【讨论】: