【发布时间】:2014-03-20 07:26:37
【问题描述】:
我有一个来自 ios 日期选择器的日期,我得到了日期和时间,并将其转换为字符串并保存在 localStorage 中。然后,我得到这个字符串日期并将其转换为 NSDate 并在我的通知中使用它。但我的问题是通知没有运行,因为转换后日期发生了变化。
选择器的时间和日期是:dateFromPicker=Thursday-20-March-2014 09:21 AM
picker 4 小时前的时间和日期是 :StringDateBefore4hours=Thursday-20-March-2014 05:21 AM
转换为NSDate后4小时前的字符串时间为:DateBefore4hours=2014-03-20 00:21:00 +0000
时间改变了,我的通知没有在选择的时间运行,请帮帮我。
【问题讨论】:
-
UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.alertBody = @"考试当天本地应用通知"; [通知 setFireDate:dateBfore4hours]; notification.timeZone = [NSTimeZone defaultTimeZone]; notification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1; [[UIApplication sharedApplication] scheduleLocalNotification:notification];
-
请告诉我们你是怎么做到的:
i get the date and the time and i convert this to string and saved in localStorage, then a get this string date and convert this to NSDate -
我的意思是我将字符串日期转换为 NSDate 形式并在通知中使用它,但转换时时间改变了
标签: ios date notifications uilocalnotification localnotification