EKCalendar错误 [英] EKCalendar Error
问题描述
我有一个应用程序以编程方式将EKEvent保存到您的iOS日历。而不是去默认日历,你选择你希望它被放置在我的日历。我有一个问题,你选择它的方式,因为一些日历工作,但不是其他人。
I have an app that programmatically saves an EKEvent to you iOS calendar. Instead of it going to the default calendar you choose the calendar you wish it to be placed in. I am having a problem with the way you are picking it because some calendars work but not others.
推荐答案
您正在设置活动的日历两次
You are setting your event's calendar twice
[event setCalendar:c];
[event setCalendar:[[eventStore calendars]objectAtIndex:calendararray]];
请告诉我你在哪里 calendararray
是一个数组?我似乎更像是一个indexKey。
Please tell me where do you get calendararray
is it an array? i seems more like an indexKey.
而不是passign你选择的日历的索引, [calendar title]
或 calendar.title
。然后使用此标题查找编辑和不可编辑的完整列表中的一个。
Instead of passign the index of your selected calendar, pass its title, like this: [calendar title]
or calendar.title
. then using this title look for the one in the complete list of edit and noneditable.
UPDATE
只要这样做:
EKCalendar *theSelectedCalendar;
// selectedCalendarTitle comes from your delegate instead of your index...
for (EKCalendar *thisCalendar in eventStore.calendars){
if ([thisCalendar.title isEqualToString:selectedCalendarTitle]){
[event setCalendar:thisCalendar];
}
}
UPDATE 2
EKCalendar *theSelectedCalendar;
// selectedCalendarTitle comes from your delegate instead of your index...
for (int i=0; i<=([eventStore.calendars count]-1); i++) {
if ([[[[eventStore calendars]objectAtIndex:i] title] isEqualToString:selectedCalendarTitle]){
[event setCalendar:[[eventStore calendars]objectAtIndex:i]];
}
}
UPDATE 3
//Present the picker populated with the array: eventStore.calendars. This should return the index and store it in: indexOfSelectedCalendarFromEventSoreCalendars
if ([[[eventStore calendars] objectAtIndex:indexOfSelectedCalendarFromEventSoreCalendars] allowsContentModifications]){
[event setCalendar:[[eventStore calendars] objectAtIndex:indexOfSelectedCalendarFromEventSoreCalendars]];
} else {
NSLog(@"Selected calendar cannot be modified."); //Present the picker again for the user to select another calendar.
}
这篇关于EKCalendar错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!