У меня возникла проблема с попыткой получить touchsBegan, чтобы ответить на мультитач.multi-touch touchhesBegan
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSSet *allTouches = [event allTouches];
for (UITouch *touch in allTouches)
{
CGPoint location = [touch locationInView:touch.view];
if(CGRectContainsPoint(snare.frame, location) && lastButton != snare) {
//Swap Image
snareImg.image = snareImgDown;
[self performSelector:@selector(swapBack) withObject:nil afterDelay:0.1];
//Play Sound
NSString *path = [[NSBundle mainBundle] pathForResource:@"snare"
ofType:@"wav"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path]
, &soundID);
AudioServicesPlaySystemSound (soundID);
//
lastButton = snare;
}
else if(CGRectContainsPoint(hiHat.frame, location) && lastButton != hiHat) {
//Play Sound
NSString *path = [[NSBundle mainBundle] pathForResource:@"hi_hat"
ofType:@"wav"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path]
, &soundID);
AudioServicesPlaySystemSound (soundID);
//
lastButton = hiHat;
}
Я не знаю о том, как получить его настройку так, что она будет реагировать на Мультитач, прямо сейчас touchesBegan работает только с 1 прессом. Я знаю что-то вроде того, что я предполагаю (UITOuch * t во что-то), я не могу вспомнить, как это работает.
Любой знает, как это сделать?
Вы установили 'multipleTouchEnabled = YES' на ваш просмотр? –