dimanche 25 mai 2014

iOS - création nouvel événement dans le calendrier d'iOS5 en ouvrant un fichier iCalendar (.ics) - Stack Overflow


According to Apple's iOS 4.2 release notes:



Calendar can now import .ics files directly as a way to add events. If your app has access to .ics files, you should test importing them using the UIDocumentInteractionController API.



I'm opening a sample .ics file using UIDocumentInteractionController and the iOS Calendar app appears, but it hasn't created a new appointment -- it just shows whatever it was showing when the Calendar app was last used. Has anyone had any luck with creating new events this way?


My code for the UIDocumentInteractionController usage is:


- (void)openDocumentIn {    
NSString * filePath =
[[NSBundle mainBundle]
pathForResource:@"testevent" ofType:@"ics"];

self.documentController =
[UIDocumentInteractionController
interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];

self.documentController.delegate = self;

[self.documentController presentOpenInMenuFromRect:CGRectZero
inView:self.view
animated:YES];
}

And my sample .ics file:


BEGIN:VCALENDAR
VERSION:1.0
BEGIN:VEVENT
DTSTART:20120411T090000
DTEND:20120411T100000
SUMMARY:Crazy party
LOCATION:Windsor Bouncy Castle
DESCRIPTION:Lots of good stuff will happen.
PRIORITY:3
END:VEVENT
END:VCALENDAR

I'm running iOS 5.1 on an original iPad.


Update


I've tried pre-creating an event in my Calendar that matches the time/data of the .ical event, to see if in this case the Calendar app would at least show the already existing event that matches, but again no luck - the calendar app just opens showing whatever was showing last time.



According to Apple's iOS 4.2 release notes:



Calendar can now import .ics files directly as a way to add events. If your app has access to .ics files, you should test importing them using the UIDocumentInteractionController API.



I'm opening a sample .ics file using UIDocumentInteractionController and the iOS Calendar app appears, but it hasn't created a new appointment -- it just shows whatever it was showing when the Calendar app was last used. Has anyone had any luck with creating new events this way?


My code for the UIDocumentInteractionController usage is:


- (void)openDocumentIn {    
NSString * filePath =
[[NSBundle mainBundle]
pathForResource:@"testevent" ofType:@"ics"];

self.documentController =
[UIDocumentInteractionController
interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];

self.documentController.delegate = self;

[self.documentController presentOpenInMenuFromRect:CGRectZero
inView:self.view
animated:YES];
}

And my sample .ics file:


BEGIN:VCALENDAR
VERSION:1.0
BEGIN:VEVENT
DTSTART:20120411T090000
DTEND:20120411T100000
SUMMARY:Crazy party
LOCATION:Windsor Bouncy Castle
DESCRIPTION:Lots of good stuff will happen.
PRIORITY:3
END:VEVENT
END:VCALENDAR

I'm running iOS 5.1 on an original iPad.


Update


I've tried pre-creating an event in my Calendar that matches the time/data of the .ical event, to see if in this case the Calendar app would at least show the already existing event that matches, but again no luck - the calendar app just opens showing whatever was showing last time.


0 commentaires:

Enregistrer un commentaire