現地時間午後6時にUIAlertNotificationを設定する必要があります。時刻は午前11時に設定され、現地の時間帯はGMT + 6:00ですので、午後6時に着きます。しかし、それは異なる時間帯で異なるでしょう。私はそれがいつでも午後6時であることを望む。誰も私を助けてくれますか?ありがとう。NSDateComponents TimeZoneについて
NSDateComponents *comps=[[[NSDateComponents alloc]init]autorelease];
[comps setYear:[year intValue]];
[comps setMonth:[month intValue]];
[comps setDay:[day intValue]];
[comps setHour:[@"11" intValue]];//6pm
[comps setMinute:0];
[comps setMinute:0];
[comps setTimeZone:[NSTimeZone localTimeZone]];
NSCalendar *cal=[[[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSDate *date1=[[cal dateFromComponents:comps]retain];
//ローカルのアラートコード
NSInteger minutesAhead = 0;
NSTimeInterval seconds = (60 * minutesAhead) * -1;
NSDate *actualFireDate = [date1 dateByAddingTimeInterval:seconds];
NSMutableDictionary *dictC = [NSMutableDictionary dictionaryWithDictionary:userInfo];
[dictC setObject:date1 forKey:@"PCOriginalReminderDate"];
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = actualFireDate;
notification.alertBody = message;
notification.userInfo = dictC;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
[notification release];
注:私は日付を印刷するとき
、それは言う:
date = "2012-04-04 18:00:00 +0000";
私はそれが午前11時はGMTだったことを意味だと思うし、 7時間(GMT + 7日の昼光)から追加して18時にします。
私はすべてを正しくやっていると思います。私は完全なコードを追加しました。親切にも、私が間違いを犯している場所を教えてください。 – Ahsan
「私が日付を印刷するとき」と言うと、何時に話していますか?また、通知の 'timeZone'プロパティも設定していません。 – yuji