문제는 내 알림이 설정 될 때까지 진행되지 않는다는 것입니다. 펜촉에 날짜 선택기를 놓고 그 아래에 단추를 놓습니다. 사용자는 피커에서 날짜를 설정하고 버튼을 클릭하여 날짜보다 60 시간 전에 알림을 설정합니다. 그래서, 나는 데이트 피커에서 날짜를 인식하도록 해고를하는 데 문제가있는 것처럼 보입니다. 이것은 사용자가 입력 선택기에서 날짜를 저장 다루는 내보기 컨트롤러에서 더 많은 코드,iOS : 지역 알림이 발효하지 않습니다.
- (IBAction)scheduleNotifButton:(id)sender {
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
NSDate *selectedDate = [self.datePicker date];
localNotif.fireDate = [selectedDate dateByAddingTimeInterval:-60*60*60];
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertBody = @"Event is in three days!";
localNotif.alertAction = nil;
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 0;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Event scheduled."
message:@"You will be notified three days before the event."
delegate:nil
cancelButtonTitle:@"Okay."
otherButtonTitles:nil];
[alert show];
}
을 그리고 여기에 도움이된다면 몇 가지 추가 코드 : 여기, 내보기 컨트롤러에 코드입니다 : 지금 3 일이 코드를 통해 파고 봤는데 그들이에 가정 할 때 내 알림을 통해하지 않을 이유를 알아낼 수 없습니다
- (IBAction)dateChanged:(id)sender
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDate *selectedDate = [self.datePicker date];
[defaults setObject:selectedDate forKey:@"ImportantDatesViewController.selectedDate"];
[defaults synchronize];
}
- (void)viewDidLoad {
NSDate *storedDate = [[NSUserDefaults standardUserDefaults]
objectForKey:@"ImportantDatesViewController.selectedDate"];
if (storedDate == nil) {
storedDate = [NSDate date];
}
[self.datePicker setDate:storedDate animated:NO];
}
. 어떤 도움이라도 대단히 감사합니다. 감사합니다!
감사합니다. 경고를 보내지 만, 사용자가 피커에 입력 한 날짜에 전혀 의존하지 않는 것 같습니다. – John