UILocalNotification *localNotification = [[UILocalNotification alloc] init];
[localNotification setFireDate:[NSDate dateWithTimeIntervalSinceNow:3600]];
[localNotification setAlertAction:@"Launch"];
[localNotification setAlertBody:[alertBodyField text]];
[localNotification setHasAction: YES];
[localNotification setApplicationIconBadgeNumber:[[UIApplication sharedApplication] applicationIconBadgeNumber]+1];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[alertNotification setHidden:NO];
質問する
226 次
2 に答える
0
繰り返し時間間隔のリストは次のとおりです。
日や月などの暦単位を指定します。
enum {
NSEraCalendarUnit = kCFCalendarUnitEra,
NSYearCalendarUnit = kCFCalendarUnitYear,
NSMonthCalendarUnit = kCFCalendarUnitMonth,
NSDayCalendarUnit = kCFCalendarUnitDay,
NSHourCalendarUnit = kCFCalendarUnitHour,
NSMinuteCalendarUnit = kCFCalendarUnitMinute,
NSSecondCalendarUnit = kCFCalendarUnitSecond,
NSWeekCalendarUnit = kCFCalendarUnitWeek,
NSWeekdayCalendarUnit = kCFCalendarUnitWeekday,
NSWeekdayOrdinalCalendarUnit = kCFCalendarUnitWeekdayOrdinal,
NSQuarterCalendarUnit = kCFCalendarUnitQuarter,
NSWeekOfMonthCalendarUnit = kCFCalendarUnitWeekOfMonth,
NSWeekOfYearCalendarUnit = kCFCalendarUnitWeekOfYear,
NSYearForWeekOfYearCalendarUnit = kCFCalendarUnitYearForWeekOfYear
NSCalendarCalendarUnit = (1 << 20),
NSTimeZoneCalendarUnit = (1 << 21),
};
typedef NSUInteger NSCalendarUnit;
あなたの場合:
繰り返し間隔をに設定すると、'NSWeekCalendarUnit'
うまくいくはずです。毎週、元の通知と同じ日時に繰り返されます。
通知音を設定する:
localNotification.soundName = UILocalNotificationDefaultSoundName; // Here you can also use custom sound .
カスタムサウンド用
localNotification.soundName = @"alarm_sound.wav";// put name of sound file
于 2013-03-02T12:08:35.557 に答える
0
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
[localNotification setFireDate:[NSDate dateWithTimeIntervalSinceNow:3600]];
[localNotification setAlertAction:@"Launch"];
[localNotification setAlertBody:[alertBodyField text]];
[localNotification setHasAction: YES];
// change
localNotification.repeatInterval = NSWeekCalendarUnit; // set the repeat interval
localNotification.soundName = UILocalNotificationDefaultSoundName; // set alert sound
[localNotification setApplicationIconBadgeNumber:[[UIApplication sharedApplication] applicationIconBadgeNumber]+1];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[alertNotification setHidden:NO];
于 2013-03-02T12:13:44.760 に答える