小编use*_*086的帖子

无需抬起手指即可从一个按钮滑动到另一个按钮

我有两个按钮(按钮1和按钮2),如果我按下按钮1,则note1开始,如果我按下按钮2,则注2开始.

所以我尝试做的是:按下按钮1(note1启动)和SLIDE到按钮2,然后按下note2开始.如同你所做的那样,你不用手指在钢琴键盘上滑动,而是从c到h发出所有音符.

我这样做了UIImageViews,我也做了UIButtons.

如果我按c1pianoview它听起来是"c".如果我按d1pianoview它听起来是"d".

但如果我滑动而不抬起手指c1pianoview,d1pianoview它只会发出"c"声.我错了什么?我也可以这样做UIButtons吗?

触地得分,但滑动不起作用.

请问有人可以帮助我吗?这是我的代码:

-(void)touchesBeganNSSet *)touches withEventUIEvent *)event
{
    UITouch *touch = [[event allTouches] anyObject];
    CGPoint location = [touch locationInView:touch.view];

    if(CGRectContainsPoint(c1pianoview.frame, location))
    { 
      NSString *path = [[NSBundle mainBundle]
      pathForResource: @"c1piano" ofType:@"mp3"];
      AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] 
          initWithContentsOfURL:[NSURL fileURLWithPathath] error:NULL];
      [theAudio play];
    }

    if(CGRectContainsPoint(d1pianoview.frame, location))
    { 
      NSString *path = [[NSBundle mainBundle]
      pathForResource: @"d1piano" ofType:@"mp3"];
      AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] 
          initWithContentsOfURL: [NSURL fileURLWithPathath] error:NULL];
      [theAudio play];
    } …
Run Code Online (Sandbox Code Playgroud)

iphone sliding touchesmoved

2
推荐指数
1
解决办法
2174
查看次数

标签 统计

iphone ×1

sliding ×1

touchesmoved ×1