我正在尝试使用 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 中的错误?

最佳答案

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

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

关于objective-c - EKCalendarChooser 多选不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9452845/

10-09 02:21