【问题标题】:EKCalendarChooser multiple selection does not workEKCalendarChooser 多选不起作用
【发布时间】:2012-03-16 04:58:37
【问题描述】:

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

【问题讨论】:

    标签: objective-c ipad ios5 uikit eventkit


    【解决方案1】:

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

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

    【讨论】:

    • 你确定吗?我不必在单选模式下执行此操作。不过在家的时候会试试的。
    • 我这样做了,但确实有帮助。我之前没有初始化 NSSet 变量。无论哪种方式,使用多项选择功能仍然对我不起作用。我在选择的实例输出所选日历,但选择后,无效,无处不在,到处都会弹出很多检查,以查看他们数据所在但没有​​被引用。我觉得苹果只是忘了实现 EKCalendarChooserSelectionStyleMultiple 类型或其他东西。因为它显然没有返回任何点击的单元格。
    • 2015,仍然需要分配初始化selectedCalendars才能使多选样式正常工作。
    猜你喜欢
    • 1970-01-01
    • 2013-07-12
    • 2013-01-15
    • 1970-01-01
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 2013-11-03
    相关资源
    最近更新 更多