iphone - EKEventStore,我需要单独使用 iOS 6 的 EventKit.Framework 吗?

标签 iphone ios6 eventkit ekeventkit

我有一个通用的 iOS 应用程序,正在努力使其与 iOS 6 兼容。我使用 Cordova/Phonegap 框架,所以我的应用程序是 HTML、CSS 和 JS。我正在使用 Cordova 的 calenderPlugin,它可以在 GitHub 上找到,在 iOS 6 之前工作正常。

问题从这里开始: 苹果补充说,从iOS 6开始,在对日历和提醒进行任何操作之前,我们需要获得用户的许可。为此,这里是示例代码:

EKEventStore    *eventStore = [[EKEventStore alloc] init];

if( [self checkIsDeviceVersionHigherThanRequiredVersion:@"6.0"] ) {

[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {

if (granted){
//---- codes here when user allow your app to access theirs' calendar.

}else
{
//----- codes here when user NOT allow your app to access the calendar.

}

:
:
}];

}


//**********************************************************************************

//   Below is a block for checking is current ios version higher than required version.

//**********************************************************************************

- (BOOL)checkIsDeviceVersionHigherThanRequiredVersion:(NSString *)requiredVersion
{
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];

if ([currSysVer compare:requiredVersion options:NSNumericSearch] != NSOrderedAscending)
{
return YES;
}

return NO;
}

当然我添加了EventKit.Framework和EventKitUI.Framework。现在的问题是, 为了开发iOS 6,我下载并安装了iOS6 SDK附带的xCode 4.5。

xCode 没有找到 requestAccessToEntityType 这个方法,常量 EKEntityTypeEvent 也不可用。

我似乎缺少 iOS 6 的 EventKit.Framework,但是怎么办?我有 xCode 4.5,它附带了 iOS 6 的 SDK。有什么建议吗?

最佳答案

问题已解决,

我通过右键单击项目下的框架并将文件添加到项目来添加 EventKit.framework。这些框架适用于 iOS 5。要添加适用于 iOS 6 的框架,首先我从框架文件夹中删除了该框架,然后转到“目标”>“摘要”>“链接的框架和库”。我按下 + 并添加了出现在 iOS 6 文件夹下的 EventKit.framework。 干杯:-) 编码愉快。

关于iphone - EKEventStore,我需要单独使用 iOS 6 的 EventKit.Framework 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12568723/

相关文章:

ios - 从导航堆栈弹出 ViewController

iphone - applicationWillEnterForeground 从未调用过

iOS 6 : UIDatePicker in the UITextField

iphone - iPhone 是否有相当于 NSTokenField 控件?

iphone - SQLite 查询中的 NSInteger 变量

iphone - iOS 6 数组格式

html - UiWebView 中的 contenteditable div - 单击完成时不保存新行

ios - 无法在 iOS 应用程序中使用 EventKit 添加事件

ios - 如何设置每周重复一次的 EKRecurrenceRule 规则

macos - 请求 EventKit 访问 macOS SwiftUI