大佬教程收集整理的这篇文章主要介绍了ios – UILocalNotification应该每个工作日重复,但周末也会发生,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
UIlocalnotification *localnotification = [[UIlocalnotification alloc] init]; localnotification.alertAction = @"View"; localnotification.alertBody = NSLocalizedString(@"ALERT_messaGE",nil); localnotification.soundName = UIlocalnotificationDefaultSoundName; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"MM-dd-yyyy HH:mm"]; [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"America/Toronto"]]; // Notification fire times are set by creaTing a notification whose fire date // is an arbitrary weekday at the correct time,and having it repeat every weekday NSDate *fireDate = [dateFormatter dateFromString:@"01-04-2012 11:00"]; localnotification.fireDate = fireDate; localnotification.repeaTinterval = NSWeekdayCalendarUnit; [[UIApplication sharedApplication] schedulelocalnotification:localnotification]; break; [localnotification release];
文档说明它更清楚一点,建议您使用1-7作为单位:
要正确设置从星期一到星期五的通知,这里有一些框架代码.你必须执行它5次,所以将其封装在一个fireDate参数的方法中是很好的.我已经展示了如何在星期一做到这一点.
UIlocalnotification *notification = [[[UIlocalnotification alloc] init] autorelease]; // Set this to an NSDate that is for the time you want,on Monday notification.fireDate = fireDate; // Repeat every week notification.repeaTinterval = NSWeekCalendarUnit;
以上是大佬教程为你收集整理的ios – UILocalNotification应该每个工作日重复,但周末也会发生全部内容,希望文章能够帮你解决ios – UILocalNotification应该每个工作日重复,但周末也会发生所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。