大佬教程收集整理的这篇文章主要介绍了iOS在特定日期设置本地通知,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
他们可以选择他们喜欢的一天中的任何时间,并可以切换一周中的不同日期(周一,周二,妻子等).通知将每周发送一次.因此,我限制用户只创建3个通知 – 如果选择了所有7天,我会将repeaTinterval设置为daily(一个通知).如果为每3个通知选择了6天,那么我将需要每天的单独通知(总共3×6 = 18个通知).很可能只会使用1个通知,所以这很好.
我知道如何在将来的某个时间设置通知,但如何在星期一下午6点设置通知?
下面是我用于测试的代码.它将来会设置4秒的警报(我从applicationDidEnterBACkground调用它).
NSDateComponents *changeComponent = [[NSDateComponents alloc] init]; changeComponent.second = 4; NSCalendar *theCalendar = [NSCalendar currentCalendar]; NSDate *itemDate = [theCalendar dateByAddingComponents:changeComponent toDate:[NSDate date] options:0]; UIlocalnotification *localNotif = [[UIlocalnotification alloc] init]; localNotif.fireDate = itemDate; localNotif.timeZone = [NSTimeZone defaultTimeZone]; localNotif.repeaTinterval = NSWeekdayCalendarUnit;
NSDateComponents *comps = [[[NSDateComponents alloc] init] autorelease]; [comps setDay:1]; [comps setMonth:1]; [comps setYear:2013]; [comps setHour:10]; [comps setminute:10]; [comps setSecond:10]; localNotif.fireDate = [[NSCalendar currentCalendar] dateFromComponents:comps];
以上是大佬教程为你收集整理的iOS在特定日期设置本地通知全部内容,希望文章能够帮你解决iOS在特定日期设置本地通知所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。