EKCalendarChooser multiple selection does not work

丶灬走出姿态 提交于 2020-01-02 06:49:44

问题


I'm trying to use EKCalendarChooser to get multiple calendars selected by the user. This is how I present the view:

EKCalendarChooser* dvc= [[[EKCalendarChooser alloc] initWithSelectionStyle:EKCalendarChooserSelectionStyleMultiple displayStyle:EKCalendarChooserDisplayAllCalendars eventStore:eventStore] autorelease];

dvc.selectedCalendars= self.selectedCalendars;
dvc.delegate= self;
dvc.contentSizeForViewInPopover= CGSizeMake(320.0, 480.0);

self.popOver= [[UIPopoverController alloc] initWithContentViewController:dvc];
[self.popOver release];
self.popOver.delegate= self;

UIBarButtonItem* item= sender;

[self.popOver presentPopoverFromBarButtonItem:item permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

I get the calendarChooserSelectionDidChange message once I select one or more calendars, but every time the selectedCalendars property of the EKCalendarChooser is empty!

- (void)calendarChooserSelectionDidChange:(EKCalendarChooser *)calendarChooser
{
   NSLog(@"selected %d calendars", calendarChooser.selectedCalendars.count);
}

2012-02-26 12:50:39.137 MyApp[8604:707] selected 0 calendars
2012-02-26 12:50:42.100 MyApp[8604:707] selected 0 calendars

When I use EKCalendarChooserSelectionStyleSingle instead of EKCalendarChooserSelectionStyleMultiple, everything works fine and I will get the correct selected calendar through the selectedCalendars property.

Am I doing anything wrong, or is this a bug in EKCalendarChooser?


回答1:


If your self.selectedCalendars are nil you have to initialize the dvc.selectedCalendars with an valid but empty set.

dvc.selectedCalendars = [[NSSet alloc] init];


来源:https://stackoverflow.com/questions/9452845/ekcalendarchooser-multiple-selection-does-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!