2012-09-24 67 views
2

我有一個通用的iOS應用程序,努力使其與iOS 6兼容。我使用Cordova/Phonegap框架,因此我的應用程序是HTML,CSS和JS。我在github上使用了calenderPlugin,它在github上可用,在iOS 6之前工作正常。 問題從這裏開始, Apple從iOS 6開始,在對日曆和提醒進行任何操作之前,我們需要向用戶授予許可。對於這裏的示例代碼,
EKEventStore,我是否需要安全地使用iOS 6的EventKit.Framework?

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 ?? !!但是如何?我有iOS 6的SDK附帶的xCode 4.5。有什麼建議嗎?

回答

0

請檢查您的BaseSDK,因爲我在使用iOS6 SDK的XCode4.5中沒有問題。不過,我通過App Store升級了我的XCode 4.5,而不是從開發網站升級。

+0

我的基礎SDK已經設置爲最新的iOS(6.0)。你用過EventKit.framework嗎?因爲我認爲我的框架中的EKEventStore類不包含方法-requestAccessToEntityType,所以iOS 6應該有單獨的新EventKit.framework。從哪裏獲得它?我瀏覽了我的系統,並且只有iPhoneOS5.0.sdk文件夾可用,我添加了這個框架。 –

2

問題解決了,

我已經通過右鍵點擊框架下的項目加入EventKit.framework和文件添加到項目。這些框架適用於iOS 5.要爲iOS 6添加框架,首先從框架文件夾中刪除此框架,然後轉到目標>摘要>鏈接框架和庫。我按了+,並添加了iOS 6文件夾下出現的EventKit.framework。 乾杯:-)快樂編碼。

+0

你應該將此標記爲答案! –

相關問題