如何在特定日期设置闹钟并每周重复重新安排
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 新手。 帮我。
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];
}
I want to set alarm on selected date and please correct my code i am new in iphone.
help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅 Apple iOS 开发人员库中的示例:
安排、注册和处理通知
Kindly see this Sample from Apple iOS Developer Library:
Scheduling, Registering, and Handling Notifications