Hola家伙。 我遇到触摸处理和UIResponder有点问题。更改FirstResponder
我的目标是管理单点触摸(移动)以与不同视图进行交互。
我向我的UIImageView添加了一个手势识别器,它向我的customViewController发送一条简单消息。它分配并显示一个自定义视图(UIButton的子类)通过点击的UIImageView。
我将能够(不必释放初始手指点按)将触摸移动发送到我新分配的自定义按钮。
看来,我的UIImageView吞下我的触摸,所以我的新Button不能感觉到手指的移动。 我试图辞去急救员,但似乎没有效果。
我的自定义按钮工作很好,但只有当我释放第一个水龙头,然后再次点击新的显示器按钮。
有什么建议吗? 预先感谢您。
一些代码在这里:
里面我的viewController我连着longPressGestureRecognizer我profileImageView是绘制围绕profileImageView一个圆形按钮。
-(void)showMenu:(UIGestureRecognizer*)gesture {
[profileImageView removeGestureRecognizer:gesture];
[profileImageView setUserInteractionEnabled:NO];
ConcentricRadius radius;
radius.externalRadius = 75;
radius.internalRadius = 45;
GTCircularButton *circularMenu = [[[GTCircularButton alloc] initWithImage:[UIImage imageNamed:@"radio.png"] highlightedImage:[UIImage imageNamed:@"radio_selected.png"] radius:radius] autorelease];
[circularMenu setTag:kCircularTagControllerCircularMenu];
[circularMenu setCenter:[profileImageView center]];
// Buttons' frames will be set up by the circularMenu
UIButton *button1 = [[[UIButton alloc] init] autorelease];
UIButton *button2 = [[[UIButton alloc] init] autorelease];
UIButton *button3 = [[[UIButton alloc] init] autorelease];
UIButton *button4 = [[[UIButton alloc] init] autorelease];
[circularMenu setButtons:[NSArray arrayWithObjects:button1, button2, button3, button4, nil]];
//[[self view] addSubview:circularMenu];
[[self view] insertSubview:circularMenu belowSubview:profileImageView];
}
现在我使用touchMoved方法手动处理circularMenu内的touchEvent。
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
CGPoint touchLocation = [(UITouch*)[touches anyObject] locationInView:self];
for (UIView *aSubview in _roundButtons) {
if ([aSubview isKindOfClass:[UIButton class]]) {
UIButton *aButton = (UIButton*)aSubview;
CGPoint buttonTouchPointConverted = [aButton convertPoint:touchLocation toView:aButton];
if (CGRectContainsPoint([[aButton layer] frame], buttonTouchPointConverted)) {
[self rotateHighlightImage:aButton];
}
}
}
}
目标始终是处理gestureRecognizer的结尾,并将触摸事件传递到创建的新实例,而不必将手指从屏幕上抬起。
任何想法?
PD:我使用touchMoved手动处理触摸,如果我使用addTarget:action:forControlEvents:在我的按钮上(1,2,3和4)检测touchEvent的按钮吞下它并使其他按钮无法感觉触摸他们。
创建触摸事件,并在事件队列中插入? – onnoweb 2011-05-27 14:27:23
我该怎么做? – Gabriele 2011-05-29 08:51:43