-1
已刪除動畫並已解決該問題。
編輯 我已經將更多的數據添加到plist文件,並且iv注意到它只是貫穿整個數據庫而不僅僅是顯示一個問題。我將如何去解決這個問題?
我有下面的代碼,在結束的時候觸發。然而在模擬器上它的工作正常,但在設備上它本身沒有。它基本上可以發出很多通話,我可以聽到多次播放的聲音。
有沒有辦法阻止這一點,並確保它只在搖動時觸發?
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
// Do your thing after shaking device
if ([plistArray count] == 0) {
self.text.text = @"Please Upgrade for more";
[Animations fadeIn:self.text andAnimationDuration:1.0 andWait:YES];
}
else {
AVAudioPlayer *showsound;
NSString *audiopath = [[NSBundle mainBundle] pathForResource:@"mouse1" ofType:@"wav"];
NSURL *audiourl = [NSURL fileURLWithPath:audiopath];
showsound = [[AVAudioPlayer alloc]initWithContentsOfURL:audiourl error:Nil];
[showsound play];
////display random quote from array
int randV = arc4random() % self.plistArray.count;
self.text.text = self.plistArray[randV];
[self.plistArray removeObjectAtIndex:randV];
//fade text in
[Animations fadeIn:self.text andAnimationDuration:1.0 andWait:YES];
//play sound
}
}
它看起來不像你過濾所有的動作類型,除了搖。 – Aaron
我已經使用波紋管代碼if(motion == UIEventSubtypeMotionShake) { //您的代碼 } – user3246508
但是,這dosent只顯示一個結果顯示所有 – user3246508