本文介绍了如何确定默认的EKCalendar“日历”是否可以隐藏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一个处理日历的应用程序。在应用程序中,我将显示所有可用日历的列表,供用户启用或禁用。我不是使用 EventKitUI 框架为我自己的设计和UI。

I'm writing an app that deals with calendars. In the app I'm displaying a list of all available calendars for the user to enable or disable. I'm not using the EventKitUI framework for purposes of my own design and UI.

我通过轮询 EKEventStore 对象的 calendars 属性得到一个整洁的日历列表。然而,在我的设备上,在 EKEventKitUI 中显示 EKCalendar $ c>。这是调试器中对象的描述:

I get a neat list of calendars by polling the calendars property of an EKEventStore object. On my device, however, there's an EKCalendar object in that list that is not shown by the EKEventKitUI. This is a description of the object in the debugger:

EKCalendar <0xcea6b60> {title = Agenda; type = Local; allowsModify = YES; color = #711A76;}



我使用荷兰语运行我的iPhone,这就是为什么标题议程而不是日历,但如果你运行的iPhone英语,这是你会看到。看起来这是iOS的默认日历,但由于我所有的日历设置为与iCloud同步,因此内置的日历应用程序被禁用。我想在我自己的应用程序中禁用它,但我不知道如何。

I'm running my iPhone in Dutch, which is why the title is 'Agenda' and not 'Calendar', but if you run the iPhone in English that's what you'll see. It looks like this is iOS' default calendar, but since I have all my calendars set up to sync with iCloud, it's disabled for the built in calendar apps. I want to disable it in my own app too, but I don't know how.

从查看的属性辨别一个决定哪个日历我应该隐藏。对于这个默认日历,有 type 属性是'Local',但是如果有人没有使用iCloud,我想所有的日历都是本地类型。 订阅不是它,也不是 allowedContentModifications 。我看到隐藏默认日历的人的示例,但正如您所看到的,标题是本地化的,因此非常不切实际,只是觉得错误。

From looking at the properties of EKCalendar I cannot discern one for deciding which calendar I should 'hide'. There's the type property that is 'Local' for this default calendar, but if someone is not using iCloud I imagine all the calendars are of a local type. subscription is not it either, nor is allowsContentModifications. I've seen examples of people hiding the default calendar based on it's title, but as you can see, the title is localized and thus very impractical, that just feels wrong.

决定哪个日历是默认日历和是否隐藏,以便平行您的常规iCal /日历应用显示的日历列表。

EDIT:问题被标记为回答,答案包含一个大不,你不能。我已通过向隐藏本地日历添加设置面板开关来解决此问题,但这是一个非常非常不起眼的解决方案。

Although the question was marked as answered, the answer contains a big "no, you can't". I've solved this issue for my users by adding a settings panel switch to 'hide local calendars', but it's a very, very unelegant solution.

推荐答案

要以粗体回答你的问题,没有一个魔法属性,你可以用来确定是否应该隐藏或显示日历。

To answer your question in bold, there isn't a magic property you can use to determine if a calendar should be hidden or displayed.

但是,如果你的理论是关于日历应用隐藏本地日历如果其他日历类型可用(iCloud / MobileMe,Exchange,CalDAV等)那么您可以使用 EKEventStore

However, if your theory is correct about the Calendar app hiding the "local" calendar if other calendar types are available (iCloud/MobileMe, Exchange, CalDAV, etc), then you can mirror its logic in your code using the EKSource array in EKEventStore

EKEventStore *store = [[EKEventStore alloc] init];

for (EKSource *source in store.sources)
    if (source.sourceType == EKSourceTypeExchange || source.sourceType == EKSourceTypeCalDAV)
    {
        //Your custom logic here to determine if the local cal should be hidden.
        break;
    }

您可以在这里找到EKSourceType常数的完整列表:

You can find the full list of EKSourceType constants here: http://developer.apple.com/library/ios/#documentation/EventKit/Reference/EKSourceClassRef/Reference/Reference.html

这篇关于如何确定默认的EKCalendar“日历”是否可以隐藏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 12:21