UIDatePicker (時刻のみ、日付なし) から UILocalNotification を設定するアラーム タイプのアプリを実装しようとしています。ユーザーがアラームを設定しようとしたときが午後 5 時であると仮定できるという事実を除いて、私はそれを機能させています。彼らが午後 4 時 45 分にアラームを設定しようとすると (次の日にこれを行うと仮定します)、UILocalNotification は設定されません。私のコード、特に「setHour」または「setMinute」、またはカレンダーでnsdatesを取得する方法が原因であると確信しています。誰かがそれを機能させるために何をする必要があるかを教えてくれれば幸いです。
UIDatePicker の名前は
datePick
ありがとう!
UILocalNotification *futureAlert;
futureAlert = [[UILocalNotification alloc] init];
NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
NSDateComponents *dateComps = [[NSDateComponents alloc] init];
//[dateComps setDay:item.day];
//[dateComps setMonth:item.month];
//[dateComps setYear:item.year];
[dateComps setHour:11];
[dateComps setMinute:46];
NSDate *itemDate = [calendar dateFromComponents:dateComps];
futureAlert.fireDate = [datePick date];
futureAlert.timeZone = [NSTimeZone defaultTimeZone];
futureAlert.alertBody= @"time to wake up";
[[UIApplication sharedApplication] scheduleLocalNotification:futureAlert];
[futureAlert release];