iwa*_*bed 8 iphone multi-touch uitouch touchesbegan
如果我在第一次触摸时抬起手指,那么它会识别下一次触摸就好了.只有当我持续第一次触摸然后尝试用不同的手指同时触摸另一个区域时.然后它将错误地将第二次触摸记录为再次从第一次触摸开始.
更新它与touchesEnded有关,直到最后的触摸结束才被调用(它不关心你是否已经有5个其他触摸结束,然后你终于放弃了最后一个...它将它们全部调用结束一旦最后的触摸结束)
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch* touch = [touches anyObject];
NSString* filename = [listOfStuff objectAtIndex:[touch view].tag];
// do something with the filename now
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
ITouch* touch = [touches anyObject];
NSString* buttonPressed = [listOfStuff objectAtIndex:[touch view].tag];
// do something with this info now
}
Run Code Online (Sandbox Code Playgroud)
小智 9
我今天有这个,(或者说我今天把这个问题丢给了我!).
我看到发生了什么:
正如Gavin Clifton所说,只有添加手势识别器才会发生这种情况.如果没有添加识别器,touchchesEnded会在每个手指释放后触发.如果我不需要使用识别器,哪个会很棒...... !!!
我通过添加gestureRotation.delaysTouchesEnded = FALSE来解决这个问题.我的识别器创建/添加代码:
gestureRotation = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(gestureRotation_Callback:)];
[gestureRotation setDelegate:self];
gestureRotation.cancelsTouchesInView = FALSE;
gestureRotation.delaysTouchesEnded = FALSE; // <---- this line!!
[self.view addGestureRecognizer: gestureRotation];
[gestureRotation release];
Run Code Online (Sandbox Code Playgroud)
现在手势工作,触摸开始不再排队!
无论出于何种原因,仅当触摸在滚动视图内时,touchesEnded才会被延迟.如果你要么a)禁止滚动滚动视图; 或者b)不使用scrollview,然后touchchesEnded立即交付.
我听说有些人拦截了sendEvent,但这对我来说似乎很粗略,我真的不想搞砸响应者链,因为sendEvent会处理很多事件.
任何额外的想法?有没有人曾经将UIWindow子类化,试图拦截那种方式?您可以提供的任何输入表示赞赏.