簡體   English   中英

輕掃手勢的多個動作

[英]Multiple actions for a swipe gesture

我正在制作一個iOS 7項目,但遇到了問題。 我希望用戶滑動,然后發生兩個動作(聲音和動作),但是只有一個動作在發生。

我已經正確設置了電源插座和收到的操作,但是沒有運氣。

現在,機芯和聲音分別起作用,但不能同時起作用。

有什么建議么

謝謝

操作碼

-(IBAction)Change3:(id)sender
{
      UIImage *img = [UIImage imageNamed:@"Image1.tif"];
      [Change3 setImage:img];
}

-(IBAction)Change2:(id)sender
{
    UIImage *img1 = [UIImage imageNamed:@"Image2.tif"];
    [Change2 setImage:img1];
}

-(IBAction)Change1:(id)sender
{
    UIImage *img2 = [UIImage imageNamed:@"Image3.tif"];
    [Change1 setImage:img2];
}

播放聲音的代碼:

    NSURL *SoundURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Jump" ofType:@".wav"]];
    AudioServicesCreateSystemSoundID((__bridge CFURLRef)SoundURL, &PlaySoundID);

您應該調用您的方法以從IBAction方法內部播放聲音。
像這樣:

-(IBAction)Change1:(id)sender
{
    UIImage *img2 = [UIImage imageNamed:@"Image3.tif"];
    [Change1 setImage:img2];

    NSURL *SoundURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Jump" ofType:@".wav"]];
    AudioServicesCreateSystemSoundID((__bridge CFURLRef)SoundURL, &PlaySoundID);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM