我的調整的一部分必須播放聲音並在收到特定消息時顯示UIAlertView。然後當UIAlertView取消時,聲音停止。使用UIAlertView無法播放聲音
此時,UIAlertView出現,但聲音未播放。這是我的代碼
#define url(x) [NSURL URLWithString:x]
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"message" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
AVAudioPlayer *mySound;
mySound = [[AVAudioPlayer alloc] initWithContentsOfURL:url(@"/Library/Ringtones/Bell Tower.m4r") error:nil];
[mySound setNumberOfLoops:-1];
[mySound play];
[alert show];
[alert release];
[mySound stop];
[mySound release];
是'網址()'各種各樣的速記? – 2011-05-27 21:39:03
是的,我編輯了代碼 – b1onic 2011-05-27 21:47:45
爲了確認,'mySound'不是'nil'吧? – 2011-05-27 21:51:48