【发布时间】:2010-08-06 18:29:19
【问题描述】:
如果我开发了一个应用程序,我们可以通过该应用程序选择日期和时间并输入文本,并且应该为本地 I 电话日历的相应日期和时间添加该文本。有什么方法可以实现吗?
【问题讨论】:
如果我开发了一个应用程序,我们可以通过该应用程序选择日期和时间并输入文本,并且应该为本地 I 电话日历的相应日期和时间添加该文本。有什么方法可以实现吗?
【问题讨论】:
是的,应该可以使用 EventKit 框架(在 iOS 4.0 中引入)。
EKEvent 是您可能正在寻找的课程。
【讨论】:
我用这个代码
EKEventStore *eventStore = [[EKEventStore alloc] init];
if ([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)])
{
// the selector is available, so we must be on iOS 6 or newer
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (error)
{
// display error message here
}
else if (!granted)
{
// display access denied error message here
}
else
{
// access granted
// ***** do the important stuff here *****
}
});
}];
}
else
{
// this code runs in iOS 4 or iOS 5
// ***** do the important stuff here *****
}
【讨论】: