本地添加及取消日期时间提醒
来源:互联网 发布:无实体软件出口 编辑:程序博客网 时间:2024/05/17 03:24
本地添加日期时间提醒
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];[calendar setTimeZone:[NSTimeZone localTimeZone]];NSDateComponents *dateComponents = [calendar components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay fromDate:[NSDate date]];NSArray * dateA = [dic[@"ReminderTime"] componentsSeparatedByString:@" "];NSArray *dateYear = [dateA.firstObject componentsSeparatedByString:@"/"];NSArray *dateTime = [dateA.lastObject componentsSeparatedByString:@":"];[dateComponents setYear:[dateYear.firstObject intValue]];[dateComponents setMonth:[dateYear[1] intValue]];[dateComponents setDay:[dateYear.lastObject intValue]];[dateComponents setHour:[dateTime.firstObject intValue]];[dateComponents setMinute:[dateTime[1] intValue]];[dateComponents setSecond:[dateTime.lastObject intValue]];NSDate *notificationDate = [calendar dateFromComponents:dateComponents];UILocalNotification *localNotif = [[UILocalNotification alloc] init];localNotif.alertBody = [NSString stringWithFormat:@"记事提醒 %@",dic[@"Title"]];localNotif.alertAction = dic[@"Title"];localNotif.soundName = UILocalNotificationDefaultSoundName;localNotif.fireDate = notificationDate;localNotif.timeZone = [NSTimeZone defaultTimeZone];NSMutableDictionary *dicUserInfo = [NSMutableDictionary dictionary];dicUserInfo = dic.mutableCopy; localNotif.userInfo = dicUserInfo;localNotif.applicationIconBadgeNumber = 1;[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
本地取消日期时间提醒
[[UIApplication sharedApplication] cancelLocalNotification:cancelNoti];
阅读全文
0 0
- 本地添加及取消日期时间提醒
- iOS 添加闹钟和取消提醒(本地通知)
- 添加本地消息提醒
- ios本地添加提醒事件
- 输入日期及提醒事件并输出
- ios 本地推送的添加和取消
- python获取本地日期时间
- pgsql日期及时间
- 英语时间及日期
- 时间及日期
- 检测日期及时间
- 用MongoVUE查看日期类型的数据时和本地时间不一致的原因及解决方案
- Snaker工作流 添加 提醒时间与提醒间隔(reminderTime、reminderRepeat)
- JS验证日期及时间
- sqlite日期函数及时间
- 日期及时间选择对话框
- greenplum 日期及时间函数
- 获取网络日期及时间
- 【动态规划】0-1背包
- 习题4.1(1)
- Ubuntu14.04 安装opencv2.4.13与opencv3.2,多版本共存
- cvSaveImage用法
- yum安装mysql本机无法连接蛋疼问题
- 本地添加及取消日期时间提醒
- ActiveMQ学习(一)了解JMS
- Android studio 开发环境变量和jni开发的环境变量的配置
- Matlab中fft函数的用法及关键问题详解
- MyBatis 学习之路
- C++中endl、“\n”和‘\n’的区别
- mybatis分页插件pagehelper的使用
- Aras 修改正则表达式验证时,错误的提示信息
- 第二章 第三课 Scratch作品:换装魔术表演(深入练习造型)