私はこれについて良い答えを得ることができず、これに多くの時間を費やすことができないので、詳細に質問します
私が望むのは、日付ピッカーに従ってアラームを作成することだけです。アラームを今から 10 秒に設定すると、うまくいきます。UIDatePicker は機能します (日付を出力しますが、選択した日付ではありませんが、3 時間後です) 現地時間に問題があることはわかっていますが、適切な説明が見つかりません。
私の提案は、ほとんどの人が現地時間に関与していないと思いますが、各ユーザーの時計を取り、その時間に応じてアラームを設定することです。
私のコードが機能していません。理由がわかりません。発火しない(10秒後に設定した場合のみ)
お願いします、タイムゾーンが異なるか何かであることは知っていますが、何をどのように行うべきかを正確に説明できれば、それは素晴らしいことです. ありがとう。
これはコードです:
-(void)setDatePicker
{
CGRect pickerFrame = CGRectMake(0,265,0,0);
UIDatePicker *myPicker = [[UIDatePicker alloc] initWithFrame:pickerFrame];
[myPicker addTarget:self action:@selector(pickerChanged:) forControlEvents:UIControlEventValueChanged];
[[[CCDirector sharedDirector] view] addSubview:myPicker];
[myPicker release];
}
-(void)pickerChanged:(UIDatePicker*) datePicker
{
date=datePicker.date;
NSLog(@"value: %@",date);
}
およびローカル通知:
-(void) scheduleNotificationForDate: (NSDate*)theDate
{
/* Here we cancel all previously scheduled notifications */
[[UIApplication sharedApplication] cancelAllLocalNotifications];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
//NSDateFormatter *dateFormat = [[[NSDateFormatter alloc]init]autorelease];
//[dateFormat setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
//NSDate *notificationDate = [dateFormat stringFromDate:theDate];
localNotification.fireDate = theDate;
NSLog(@"Notification will be shown on: %@",localNotification.fireDate);
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.alertBody = [NSString stringWithFormat:
@"Your notification message"];
localNotification.alertAction = NSLocalizedString(@"View details", nil);
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = -1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}