1
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
   return;

localNotif.fireDate = selected;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.repeatCalendar = [NSCalendar currentCalendar];

if (isSun) {
    [components setWeekday:1];
    [localNotif setRepeatInterval:(NSInteger)components];
}

if (isMon) {
    [components setWeekday:2];
    [localNotif setRepeatInterval:(NSInteger)components];   
}

if (isTue) {
    [components setWeekday:3];
    [localNotif setRepeatInterval:(NSInteger)components];
}

if (isWed) {
    [components setWeekday:4];
    [localNotif setRepeatInterval:NSWeekCalendarUnit];
}

if (isThu) {
    [components setWeekday:5];
    [localNotif setRepeatInterval:(NSInteger)components];
}

if (isFri) {
    [components setWeekday:6];
    [localNotif setRepeatInterval:(NSInteger)components];
}

if (isSat) {
    [components setWeekday:7];
    [localNotif setRepeatInterval:(NSInteger)components];
}

我想在选定的日期设置闹钟,请更正我的代码,我是 iphone 的新手。帮我。

4

1 回答 1

2

请从 Apple iOS 开发人员库中查看此示例:

调度、注册和处理通知

于 2011-04-17T11:36:43.943 回答