我有一個應用程序,我有按鈕。當我點擊按鈕,然後生成本地通知。本地通知的變量在appDelegate文件中設置。爲了生成本地通知,我使用了以下代碼: -如何更改本地通知的聲音名稱?
UILocalNotification * ln = [[UILocalNotification alloc] init]; ln.alertBody = @「又來一杯咖啡的時間!」; ln.applicationIconBadgeNumber = 1; ln.fireDate = notification_date; // [NSDate dateWithTimeIntervalSinceNow:15]; ln.timeZone = [NSTimeZone timeZoneWithAbbreviation:@「GMT」]; NSString * string_date = [formatter stringFromDate:notification_date]; NSDateFormatter * formatter_alarm = [[[NSDateFormatter alloc] init] autorelease]; formatter_alarm.timeZone = [NSTimeZone timeZoneWithAbbreviation:@「GMT」]; [formatter_alarm setDateFormat:@「hh:mm a」]; NSString * str = [formatter_alarm stringFromDate:notification_date]; appDelegate.alarm_time = [NSString stringWithFormat:@「%@」,str]; NSLog(@「%@」,appDelegate.alarm_time);
[[NSUserDefaults standardUserDefaults] setObject:appDelegate.alarm_time forKey:@"alarm_on_time"];
[[NSUserDefaults standardUserDefaults] setObject:string_date forKey:@"alarm_on_date"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSLog(@"alarm will activate on%@",notification_date);
ln.soundName = @"alarm.wav";
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
ln.repeatInterval=NSDayCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:ln];
//如果(appDelegate.appDelegate_notification ==無) // appDelegate.appDelegate_notification = [[UILocalNotification的alloc] INIT]; appDelegate.appDelegate_notification = ln; [發佈];
現在我有另一個按鈕,用於改變本地通知的聲音。我不想當用戶點擊那個按鈕,然後改變本地通知的聲音。爲此,我使用此代碼: -
appDelegate.appDelegate_notification.soundName = @「Blow.wav」;
現在的問題是,當我點擊另一個按鈕,然後本地通知的聲音沒有改變。如何使按鈕點擊該事件?
感謝在進步......