0

我这样做是为了在设定的时间获得警报。但它没有及时报警。我正在从 datepicker 设置时间。我怎样才能解决这个问题?

- (void)scheduleNotificationWithInterval:(int)minutesBefore {

      [[UIApplication sharedApplication] cancelAllLocalNotifications];

      UILocalNotification *localNotif = [[UILocalNotification alloc] init];
      if (localNotif == nil)
          return;
      NSLog(@"Date %@",datePicker.date);
      localNotif.fireDate = datePicker.date;
      localNotif.timeZone = [NSTimeZone defaultTimeZone];
      if ([freq isEqualToString:@"Daily"]) {
          localNotif.repeatInterval = NSDayCalendarUnit;
      }

      localNotif.alertBody = @"Radio Asia Alarm";
      localNotif.alertAction = @"Ok";

      localNotif.soundName = UILocalNotificationDefaultSoundName;

      NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"Radio Asia Alarm" forKey:@"Message"];
      localNotif.userInfo = infoDict;

      [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
      [localNotif release];
}

我也调用此方法,在设置时间和日期后单击按钮

  [self scheduleNotificationWithInterval:1]; 

我没有警觉。我可以做什么?

4

1 回答 1

1

你确定你设置了正确的时区吗?我确定问题可能在那里

你试过不设置吗?

于 2012-04-12T07:35:36.847 回答