2012-11-14 33 views
0

在我的應用程序,我必須將事件添加到iPhone默認calendar.I寫的代碼如下活動在iPhone 5的默認日曆中不添加

EKEventStore *eventStore = [[EKEventStore alloc] init]; 
EKEvent *event1 = [EKEvent eventWithEventStore:eventStore]; 
event1.notes=descriptionStr; 
event1.startDate =edate; 
event1.endDate=fdate; 
[event1 setTimeZone:[NSTimeZone systemTimeZone]]; 
[event1 setCalendar:[eventStore defaultCalendarForNewEvents]]; 

問題是與Iphone5的。對於4S和以前的版本,事件正在完美添加。請指導我,謝謝。

+1

你檢查你是否可以訪問日曆:['+(EKAuthorizationStatus)authorizationStatusForEntityType:(EKEntityType)entityType'](http://developer.apple.com/library/ios/#documentation/EventKit/Reference/EKEventStoreClassRef /Reference/Reference.html#//apple_ref/doc/uid/TP40009567-CH1-SW47) – rckoenes

+0

不,我沒有檢查,其工作正常4秒,我必須使應用程序兼容ios6。你可以更詳細地解釋@rckoenes – Krish

+0

閱讀上面鏈接中的Apple文檔,我還沒有在iOS 6中使用過使用過的EventKit。 – rckoenes

回答

1

根據EKEventStoreClassRef的蘋果文檔:

在iOS 5和後,初始化用默認init方法事件存儲對象。在iOS 6和更高版本中,在使用requestAccessToEntityType初始化事件存儲之後,必須請求訪問實體類型:完成:要返回數據。

它是否適用於安裝了iOS 6的4S?

+0

Thanq迴應,事件正在爲iOS 4添加4S,而不是Iphone 5.我從未處理過與ekevents之前,可以ü詳細解釋plz @ lammert – Krish

+1

從蘋果有一個很好的指導這個主題:[日曆和提醒編程指南](http://developer.apple.com/library/ios/#documentation/DataManagement /Conceptual/EventKitProgGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40009765) – lammert