EKCalendarChooser多重选择不起作用

时间:2012-02-26 11:57:22

标签: objective-c ipad ios5 uikit eventkit

我正在尝试使用EKCalendarChooser来获取用户选择的多个日历。这就是我呈现视图的方式:

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];

我选择一个或多个日历后会收到calendarChooserSelectionDidChange消息,但每次EKCalendarChooser的selectedCalendars属性为空时都会显示!

- (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

当我使用EKCalendarChooserSelectionStyleSingle代替EKCalendarChooserSelectionStyleMultiple时,一切正常,我会通过selectedCalendars属性获得正确的选定日历。

我做错了什么,或者这是EKCalendarChooser中的错误?

1 个答案:

答案 0 :(得分:4)

如果您的self.selectedCalendars为零,则必须使用有效但空的集初始化dvc.selectedCalendars

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