SystemSoundID shake_sound_male_id = 0; NSString *thesoundFilePath = [[NSBundle mainBundle] pathForResource:@"ReceivedMessage" ofType:@"caf"]; //音樂文件路徑 CFURLRef thesoundURL = (CFURLRef)CFBridgingRetain([NSURL fileURLWithPath:thesoundFilePath]); AudioServicesCreateSystemSoundID(thesoundURL, &shake_sound_male_id); AudioServicesPlaySystemSound(shake_sound_male_id); AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);//播放震動
AudioServicesPlaySystemSound(1004); //更換播放系統的聲音 id值能夠百度查詢 AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);//震動
dispatch_async(dispatch_get_main_queue(), ^{ _lbName=@"Name"; });
//這樣實現延時調用是錯誤的,playSound是不會被調用的 能夠在主線程調用 dispatch_async(dispatch_get_global_queue(2, 0), ^{ [self performSelector:@selector(playSound) withObject:nil afterDelay:0.5f];//NSTimer 也須要注意這點 });
//這個是抄的 原地址http://www.cocoachina.com/bbs/read.php?tid=193276 [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(playSound) object:nil]; [self performSelector:@selector(playSound) withObject:nil afterDelay:0.5f];
之後要多記錄一下咯,很短覺得能記住,過段時間又忘了,又要打開之前的項目來看,本身記憶力真的不行,之後就多php
記錄下。async