[英]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.