あなたは二つの異なるdatePickersを持っているように見えます
うんざり? datePicker
とdatePicker1
?どうしたの?
また、これはあなたが期待している何をしていません。将来的には丁度31449600秒で新しい日付を作成している
NSDate *newDate1 = [now dateByAddingTimeInterval:60*60*24*364];
を。それ以外のことはではなく、です。
何がやりたいことは、現在の日付からの日付のすべてのコンポーネントを抽出し、それらをゼロである:
NSDate *now = [NSDate date];
NSDateComponents *nowComponents = [[NSCalendar currentCalendar] components:(NSEraCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:now];
// technically these next lines are unnecessary, since we only pulled out the era-year-month-day, but they're included here for understanding/completeness:
[nowComponents setHour:0];
[nowComponents setMinute:0];
[nowComponents setSecond:0];
// now we can turn it back into a date:
NSDate *todayAtMidnight = [[NSCalendar currentCalendar] dateFromComponents:nowComponents];
http://stackoverflow.com/questions/5358678/how-do-を参照してください。 i-set-an-existing-nsdates-time – Glenn