大佬教程收集整理的这篇文章主要介绍了objective-c – 目标C-iCal未在iOS 9中为其创建自定义日历和新事件,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
但是在iOS 9中创建问题.这里是代码:
self.eventManager.eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted,NSError *error) { if (granted) { // Create a new calendar. EKCalendar *calendar = [EKCalendar calendarForEntityType:EKEntityTypeEvent eventStore:self.eventManager.eventStore]; // Set the calendar title. calendar.title = @"<APP name>"; calendar.CGColor=APP_Blue_COLOR.CGColor; // Find the proper source type value. for (int i=0; i<self.eventManager.eventStore.sources.count; i++) { EKsource *source = (EKsource *)[self.eventManager.eventStore.sources objectATindex:i]; EKsourceType currentsourceType = source.sourCEType; if (currentsourceType == EKsourceTypeLocal) { calendar.source = source; break; } } // Save and commit the calendar. NSError *error; [self.eventManager.eventStore saveCalendar:calendar commit:YES error:&error]; // If no error occurs then turn the ediTing mode off,store the new calendar identifier and reload the calendars. if (error == nil) { // Turn off the edit mode. // Store the calendar identifier. [self.eventManager saveCustomcatalendarIdentifier:calendar.calendarIdentifier];self.eventManager.SELEctedCalendarIdentifier=calendar.calendarIdentifier;//chirag } else{ // Display the error description to the debugger. NSLog(@"CREATE_CALENDER %@",[error localizedDescription]); } } else { UIAlertView *alert=[[UIAlertView alloc] initWithtitle:@"" message:@"Please give permission to access your iPhone calender." delegate:nil cancelButtontitle:@"Ok" otherButtontitles: nil]; [alert show]; } }];
它给了我成功的消息,但没有在iPhone日历中创建我的应用程序日历.
我虽然因为没有设置事件而没有显示它.所以我也尝试设置新事件.
// Create a new event object. EKEvent *event = [EKEvent eventWithEventStore:self.eventManager.eventStore]; // Set the event title. event.title = title; // Set its calendar. event.calendar = [self.eventManager.eventStore calendarWithIdentifier:self.eventManager.SELEctedCalendarIdentifier]; // Set the start and end dates to the event. event.startDate = startDate; event.endDate = endDate; // Save and commit the event. NSError *error; if ([self.eventManager.eventStore saveEvent:event span:EKSpanThisEvent commit:YES error:&error]) { // Call the delegate method to notify the caller class (the ViewController class) that the event was saved. return true; } else{ // An error occurred,so log the error description. NSLog(@"%@",[error localizedDescription]); return false; }
Error getTing shared calendar invitations for entity types 3 from daemon: Error Domain=EKCADErrorDomain Code=1014 "(null)"
for (EKsource *source in self.eventStore.sources) { if (source.sourCEType == EKsourceTypeCalDAV && [source.title isEqualToString:@"iCloud"]) //This is a patch. { localsource = source; break; } } if (localsource == nil) { for (EKsource *source in self.eventStore.sources) { if (source.sourCEType == EKsourceTypeLocal) { localsource = source; break; } } }
以上是大佬教程为你收集整理的objective-c – 目标C-iCal未在iOS 9中为其创建自定义日历和新事件全部内容,希望文章能够帮你解决objective-c – 目标C-iCal未在iOS 9中为其创建自定义日历和新事件所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。