问题描述
我正在尝试使用 EKCalendarChooser
来获取用户选择的多个日历。这就是我呈现视图的方式:
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];
我选择 calendarChooserSelectionDidChange
消息一个或多个日历,但每次 EKCalendarChooser
的selectedCalendars属性为空时!
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
当我使用 EKCalendarChooserSelectionStyleSingle
而不是 EKCalendarChooserSelectionStyleMultiple
,一切正常,我将通过selectedCalendars属性获得正确的选定日历。
When I use EKCalendarChooserSelectionStyleSingle
instead of EKCalendarChooserSelectionStyleMultiple
, everything works fine and I will get the correct selected calendar through the selectedCalendars property.
Am我做错了什么,或者这是 EKCalendarChooser
中的错误?
Am I doing anything wrong, or is this a bug in EKCalendarChooser
?
推荐答案
如果 self.selectedCalendars
为nil,则必须使用有效但空的集初始化 dvc.selectedCalendars
。
If your self.selectedCalendars
are nil you have to initialize the dvc.selectedCalendars
with an valid but empty set.
dvc.selectedCalendars = [[NSSet alloc] init];
这篇关于EKCalendarChooser多重选择不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!