사용자가 UITextField에 데이터를 입력 할 수있는 앱을 작성했으며 그 중 하나를 사용하여 특정 날짜에 입력 할 수 있습니다. 앱이 전혀 실행되지 않아도 15 시간이 지나면 iPhone 알림 센터에 알림을 표시하려고합니다.iPhone : 알림 센터 문제
편집 : [-dateByAddingTimeInterval:]
를 호출하기 위해 새로운 코드 -
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ UILocalNotification *localNotif = [[UILocalNotification alloc] init];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMdd"];
NSDate *eventDate=[dateFormatter dateFromString:eventDateField.text];
localNotif.fireDate = [eventDate dateByAddingTimeInterval:-15*60*60];
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertBody = @"Event Tomorrow!";
localNotif.alertAction = @"Show me";
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 0;
[[UIApplication sharedApplication]presentLocalNotificationNow:localNotif];
}
약간 가혹한 점에 대해 사과드립니다.하지만 매우 기본적인 (중요한) 기본 사항이 부족합니다. 너 자신을 호의하고 배우십시오; 그것은 오래 걸리지 않을 것이고 결국 많은 시간과 좌절을 구할 것입니다. 내가 추천 할 수있는 아주 좋은 책은 [iOS 프로그래밍 : The Big Nerd Ranch Guide] (http://www.amazon.com/iOS-Programming-Ranch-Guide-Guides/dp/0321773772/)입니다. 멋지게 작성되었으며, 기초를 다루고 (특히 * 당신이 묻고있는 것들) 멋진 예제를 담고 있습니다. 호의를 베풀고, 읽고, 연습을하십시오. 오래 걸리지는 않겠지 만 대단히 도움이 될 것입니다. – fzwo
감사합니다. fzwo, 예, 확실히 여기저기서 약간 뛰어 올랐습니다. 오늘 그 책을 살펴볼 것입니다. 고마워요! – John