2011-11-20 144 views
1

我正在做一个iPad的日历,直到现在为止 我有日历视图,但是现在我需要在其中创建一个事件。 我基地在这个例子与YFCalendar http://www.yellowfield.co.uk/blog/?p=28如何在日历中添加事件

现在我需要添加可通过当天

不过,我想看到一个小窗口事件的总结时添加一个新的事件类似于默认日历。

Example_Image: http://media.wiley.com/Lux/45/271245.image1.jpg

我不知道我需要什么样的控制来实现这一结果。

我不使用默认日历

有些建议吗? 最好的东西用开源来分析,以任何方式,任何答案,欢迎

回答

0

参阅事件套件编程指南位于:

http://developer.apple.com/library/ios/#documentation/DataManagement/Conceptual/EventKitProgGuide/Introduction/Introduction.html

下面是苹果的示例代码:https://developer.apple.com/library/ios/samplecode/SimpleEKDemo/Introduction/Intro.html

的用于添加事件的代码使用EKEventEditViewController:

// Create an instance of EKEventEditViewController 
EKEventEditViewController *addController = [[EKEventEditViewController alloc] init]; 

// Set addController's event store to the current event store 
addController.eventStore = self.eventStore; 
addController.editViewDelegate = self; 
[self presentViewController:addController animated:YES completion:nil]; 

加入后,您可以获取使用代码来自教程,检索事件与谓词(在这种情况下日期)事件:

NSDate *startDate = [NSDate date]; 

//Create the end date components 
NSDateComponents *tomorrowDateComponents = [[NSDateComponents alloc] init]; 
tomorrowDateComponents.day = 1; 

NSDate *endDate = [[NSCalendar currentCalendar] dateByAddingComponents:tomorrowDateComponents 
                   toDate:startDate 
                   options:0]; 
// We will only search the default calendar for our events 
NSArray *calendarArray = [NSArray arrayWithObject:self.defaultCalendar]; 

// Create the predicate 
NSPredicate *predicate = [self.eventStore predicateForEventsWithStartDate:startDate 
                    endDate:endDate 
                   calendars:calendarArray]; 

// Fetch all events that match the predicate 
NSMutableArray *events = [NSMutableArray arrayWithArray:[self.eventStore eventsMatchingPredicate:predicate]]; 

return events; 
+0

让我检查一下,它会为我服务以及将为其接受我的个人日历并使用JSON将数据发送到Web平台? 我不使用本地日历 谢谢 –

+0

非常感谢你我正在看教程现在, –

+0

我看了视频,它很有用,但我不使用默认日历,所以我不知道是否需要其他类型的东西,因为我使用JSON在网络平台中添加事件 –