UIView子类忽略第二触摸
问题描述:
我做的是iOS游戏,我写的是应该赶上触摸事件的UIView子类,它可以作为用于单点触摸。但是,如果我已经用一根手指触摸屏幕,然后用其他手指的另一个手指触摸它,“touchesBegan”不会被要求进行第二次触摸。UIView子类忽略第二触摸
下面是类的实现:(的Objective-C++)
#import "BATouchInput.h"
#include "BotsApp.h"
@implementation BATouchInput
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
for (UITouch* touch in touches) {
std::cout << "touch started" << std::endl;
BotsApp::getSingletonPtr()->touchDown(touch);
}
std::cout << "--------------" << std::endl;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
std::cout << [touches count] << std::endl;
for (UITouch* touch in touches) {
BotsApp::getSingletonPtr()->touchMoved(touch);
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
for (UITouch* touch in touches) {
BotsApp::getSingletonPtr()->touchUp(touch);
}
}
@end
我通过这段代码创建这个类的一个实例:
BATouchInput * touchRecieverView = [[BATouchInput alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame]];
[[[UIApplication sharedApplication] keyWindow] addSubview: touchRecieverView];