如何实现闹钟的周期提醒功能?

各位大神,你们好
现在所说的是IOS开发
我现在要实现一个闹钟功能,具体为类似于每周一、每周三、每周四、每周日同一时间提醒的功能。
我在这里不是要问怎么使用iPhone
我是要问代码应该如何实现
在具体一点就是使用localnotification,但是具体应该怎么用,我并没有一个思路。
求大神指点,最好上代码,谢谢。

阅读 7.2k
2 个回答
UILocalNotification *notification = [[UILocalNotification alloc]  init];
notification.fireDate = yourDate; // 周一早上八点
notification.timeZone = [NSTimeZone localTimeZone];
notification.alertBody = @"xxx";
notification.repeatInterval = NSWeekCalendarUnit;
notification.soundName = UILocalNotificationDefaultSoundName;

[[UIApplication sharedApplication] scheduleLocalNotification:notification];

notification = [[UILocalNotification alloc]  init];
notification.fireDate = yourDate; // 周三早上八点
notification.timeZone = [NSTimeZone localTimeZone];
notification.alertBody = @"xxx";
notification.repeatInterval = NSWeekCalendarUnit;
notification.soundName = UILocalNotificationDefaultSoundName;

[[UIApplication sharedApplication] scheduleLocalNotification:notification];

notification = [[UILocalNotification alloc]  init];
notification.fireDate = yourDate; // 周四早上八点
notification.timeZone = [NSTimeZone localTimeZone];
notification.alertBody = @"xxx";
notification.repeatInterval = NSWeekCalendarUnit;
notification.soundName = UILocalNotificationDefaultSoundName;

[[UIApplication sharedApplication] scheduleLocalNotification:notification];

…………
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题