【发布时间】:2014-08-06 01:42:55
【问题描述】:
我的应用程序是关于显示学生时间表的,我想添加一个本地通知repeatInterval。
我打算为此使用切换按钮。
我试过这段代码,但它现在不起作用:
-(IBAction)theSwitch:(id)sender{
if (switcher.on) {
NSCalendar *gregCalendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *dateComponent = [gregCalendar components:NSYearCalendarUnit | NSWeekCalendarUnit fromDate:[NSDate date]];
[dateComponent setWeekday:3]; // For tuesday
[dateComponent setHour:13];
[dateComponent setMinute:41];
NSDate *fireDate = [gregCalendar dateFromComponents:dateComponent];
UILocalNotification *notification = [[UILocalNotification alloc]init];
[notification setAlertBody:@"ALARM!"];
[notification setFireDate:fireDate];
notification.repeatInterval = NSWeekCalendarUnit;
[notification setTimeZone:[NSTimeZone defaultTimeZone]];
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
else {UIApplication *app=[UIApplication sharedApplication];
[app scheduleLocalNotification:nil];
}
}
因此,我需要在这方面提供更多指导,并就如何实现这一目标提出一些建议。
【问题讨论】:
-
您面临的问题是什么?没有通知或补货问题?
-
问题是当我打开我的应用程序时出现故障
标签: ios notifications uilocalnotification