У меня есть несколько вопросов по мультитач
это часть моего кода в файле .m
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint pt = [touch locationInView:self.view];
if(pt.x>634 && pt.x<733 && pt.y >64 && pt.y<145)
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"si" ofType:@"mp3"];
theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio play];
}
if(pt.x>634 && pt.x<733 && pt.y >195 && pt.y<276)
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"la" ofType:@"mp3"];
theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio play];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSString *path = [[NSBundle mainBundle] pathForResource:@"rest" ofType:@"mp3"];
theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio play];
}
Надеюсь, это сработает.
На самом деле, вторая часть «if ((диапазон) &&(диапазон))» не работает. Может ли кто-нибудь сказать мне решение?
Первый диапазон работает, и я хочу, чтобы второй диапазон воспроизводил «la.mp3», но когда 2 пальца касаются, музыка не воспроизводится.