【发布时间】:2016-02-16 14:29:29
【问题描述】:
我被这个奇怪的问题困住了。我正在制作一个警报应用程序。当我触发本地通知时,它在模拟器中运行良好,但是当我在 iPhone 中编译代码时它不起作用。相同的代码在模拟器上运行,但在 iPhone 上没有响应。
通知代码:
-(void) scheduleLocalNotificationWithDate:(NSDate *)fireDate
{
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = fireDate;
localNotif.alertBody = @"Time to wake Up";
localNotif.alertAction = @"Show me";
localNotif.soundName = @"Tick-tock-sound.mp3";
localNotif.applicationIconBadgeNumber = 1;
localNotif.repeatInterval = NSCalendarUnitWeekOfYear;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}
保存按钮代码为:
- (IBAction)saveBtn:(id)sender {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.timeZone = [NSTimeZone localTimeZone];
NSLog(@"time is %@",dateFormatter.timeZone);
dateFormatter.timeStyle = NSDateFormatterShortStyle;
NSString * dateTimeString = [dateFormatter stringFromDate:timePicker.date];
datesArray = @[[dateFormatter stringFromDate:self.timePicker.date]];
}
请告诉我解决方案。谢谢
【问题讨论】:
标签: ios timezone uilocalnotification