我的项目中的三个声音:
} - (IBAction)Sound1:(NSDate *) fireDate;
{
[[NSUserDefaults standardUserDefaults] setObject:@"Sound1.aiff" forKey:@"UserSoundChoice"];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
[localNotification setFireDate:[NSDate date]];
[localNotification setTimeZone:[NSTimeZone defaultTimeZone]];
[localNotification setAlertBody:@"Alarm went off!"];
[localNotification setAlertAction:@"View"];
[localNotification setHasAction:YES];
localNotification.soundName= [[NSUserDefaults standardUserDefaults] objectForKey:@"UserSoundChoice"];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
- (IBAction)Sound2:(NSDate *) fireDate;
{
[[NSUserDefaults standardUserDefaults] setObject:@"Sound2.aiff" forKey:@"UserSoundChoice"];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
[localNotification setFireDate:[NSDate date]];
[localNotification setTimeZone:[NSTimeZone defaultTimeZone]];
[localNotification setAlertBody:@"Alarm went off!"];
[localNotification setAlertAction:@"View"];
[localNotification setHasAction:YES];
localNotification.soundName= [[NSUserDefaults standardUserDefaults] objectForKey:@"UserSoundChoice"];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
- (IBAction)Sound3:(NSDate *) fireDate;
{
[[NSUserDefaults standardUserDefaults] setObject:@"Sound3.aiff" forKey:@"UserSoundChoice"];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
[localNotification setFireDate:[NSDate date]];
[localNotification setTimeZone:[NSTimeZone defaultTimeZone]];
[localNotification setAlertBody:@"Alarm went off!"];
[localNotification setAlertAction:@"View"];
[localNotification setHasAction:YES];
localNotification.soundName= [[NSUserDefaults standardUserDefaults] objectForKey:@"UserSoundChoice"];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
- (IBAction)SetDatePicker
{
NSDateFormatter *dateFormatter =[ [NSDateFormatter alloc] init];
dateFormatter.timeZone = [NSTimeZone defaultTimeZone];
dateFormatter.timeStyle = NSDateFormatterShortStyle;
dateFormatter.dateStyle = NSDateFormatterShortStyle;
NSString *dateTimeString = [dateFormatter stringFromDate: dateTimePicker.date];
NSLog (@"Alarm saved: %@", dateTimeString);
[self Sound1:dateTimePicker.date];
[self Sound2:dateTimePicker.date];
[self Sound3:dateTimePicker.date];
}
-(void)scheduleLocalNotificationWithDate:(NSDate *)fireDate
{
UILocalNotification *notifiction =[[UILocalNotification alloc]init];
notifiction.FireDate = fireDate;
notifiction.AlertBody = @"Wake Up!!!";
notifiction.soundName =UILocalNotificationDefaultSoundName;
notifiction.repeatInterval= NSMinuteCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification: notifiction];
}
我想让用户选择其中一个来将其设置为通知声音我一直在搜索很多但我没有找到任何可以帮助我的解决方案