2013-02-03 46 views
2

對於尚未創建的通知(新通知)更改,但對於已創建的通知,先前的聲音保留。更改已設置的UILocalNotification的聲音名稱

我曾嘗試:

NSString *soundName = cell.titleLabel.text; 

NSArray *notifications = [[UIApplication sharedApplication] scheduledLocalNotifications]; 

for (UILocalNotification *notif in notifications) { 
    notif.soundName = [NSString stringWithFormat:@"%@.mp3", soundName]; 
} 

,但它不工作...

回答

1

你必須重新安排您安排的通知。但請確保您刪除了您之前預定的那些。

NSArray *notifications = [[UIApplication sharedApplication] scheduledLocalNotifications]; 
[[UIApplication sharedApplication] cancelAllLocalNotifications]; 

for (UILocalNotification *notif in notifications) { 
    notif.soundName = [NSString stringWithFormat:@"%@.mp3", soundName]; 
    [[UIApplication sharedApplication] scheduleLocalNotification:notification]; 
}