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的新手。 帮助我。
答案 0 :(得分:2)
请参阅Apple iOS Developer Library中的此示例: