我有一个应用程序,我有按钮。当我点击按钮,然后生成本地通知。本地通知的变量在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”;
现在的问题是,当我点击另一个按钮,然后本地通知的声音没有改变。如何使按钮点击该事件?
感谢在进步......