Well, in my application there is textfield, which contains some date. Textfield is not editable for user, but it calling for popover with calendar (Tapku Calendar, BTW). I need to paste selected date in calendar into this textfield. I’v trying this code, but it didn’t working for me.
Code in Calendar_Popover_Controller.m:
// grab (NSString*)Date from calendar and sending it to ChekIn field
- (void)calendarMonthView:(TKCalendarMonthView *)monthView didSelectDate:(NSDate *)d {
NSDate *calendarSelectedDate = [[NSDate alloc] init];
/* Here is formattedDate */
calendarSelectedDate = [calendar dateSelected];
DateForMainView = [formattedDate stringFromDate:calendarSelectedDate];
ViewController *submittedDateToMainView = [[ViewController alloc] init];
submittedDateToMainView.CheckInField.text = [formattedDate stringFromDate:calendarSelectedDate];
}
Also I’ve check other variant. It seems like this:
Calendar_Popover_Controller.m
- (void)calendarMonthView:(TKCalendarMonthView *)monthView didSelectDate:(NSDate *)d {
NSDate *calendarSelectedDate = [[NSDate alloc] init];;
/* formattedDate */
calendarSelectedDate = [calendar dateSelected];
DateForMainView = [formattedDate stringFromDate:calendarSelectedDate];
ViewController *submittedDateToMainView = [[ViewController alloc] init];
submittedDateToMainView.DateFromCalendar = DateForMainView;
}
Code in ViewController.m:
- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController {
[CheckInField setText:DateFromCalendar];
NSLog(@"For CheckIn TextField DateFromCalendar is: %@", DateFromCalendar);
NSLog(@"popover about to be dismissed");
return YES;
}
Here DateFromCalendar == nil anyway. I have no idea to solve this problem.
The
ViewControlleryou are using in thecalendarMonthView:didSelectDate:method is not the one showing on the screen, because you initialize a new one when doingViewController *submittedDateToMainView = [[ViewController alloc] init];You need to keep a reference to your existing
ViewControllerin yourCalendar_Popover_Controllerand set theDateFromCalendaron that one.