我正在尝试使用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
中的错误?
答案 0 :(得分:4)
如果您的self.selectedCalendars
为零,则必须使用有效但空的集初始化dvc.selectedCalendars
。
dvc.selectedCalendars = [[NSSet alloc] init];