EKCalendarItem
具有「位置」屬性,但它是NSString
。 新的iOS8功能顯示了一個不錯的活動地圖,因此必須有CLLocationCoordinate2D
附加到EKCalendarItem
,對嗎? 我在哪裏可以找到這CLLocationCoordinate2D
?從日曆事件(EKCalendarItem/EKEvent)中檢索位置lat/long(CLLocationCoordinate2d)
回答
這應該得到你所需要的:
for (EKEvent *calEvent in self.allMyEvents) {
EKStructuredLocation *location = (EKStructuredLocation *)[calEvent valueForKey:@"structuredLocation"];
if (location) {
}
}
EKCalendarItem
不包含任何CLLocationCoordinate2D屬性它具有location
這就是NSString
正如您在您的問題中提到的。
您可以使用location
屬性來獲得座標。您可以使用CoreLocation
框架的CLGeocoder
從字符串中獲取座標。
您可以使用此代碼。
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:locationString completionHandler:^(NSArray *placemarks, NSError *error) {
if([placemarks count]) {
CLPlacemark *placemark = [placemarks objectAtIndex:0];
CLLocation *location = placemark.location;
CLLocationCoordinate2D coordinate = location.coordinate;
NSLog(@"coordinate = (%f, %f)", coordinate.latitude, coordinate.longitude);
}
}];
這裏locationString
是從EKCalendarItem
的位置屬性中檢索到的位置字符串。默認的iCal應用程序必須做類似的事情,希望這可以幫助你。
謝謝Bhumit。是的,我在一些應用中使用了這個功能,但[placemarks objectAtIndex:0];並不總是正確的位置。我認爲該位置存儲在EKStructuredLocation https://developer.apple.com/LIBRARY/IOS/documentation/EventKit/Reference/EKStructuredLocationClassRef/index.html#//apple_ref/occ/cl/EKStructuredLocation只需做一些測試即可找出如何去... – 2014-10-01 02:26:11
'EKStructuredLocation'是'EKAlarm'的財產所以我懷疑它是用於日曆項目,反正我們不希望看到周圍希望我們有更好的方式來實現這個 – 2014-10-01 05:16:28
發現它! NSArray * eventList = [self.eventStore eventsMatchingPredicate:fetchCalendarEvents]; for(int i = 0; i
- 1. 從Google日曆中檢索事件
- 2. Google日曆PHP從多個日曆中檢索事件
- 3. 如何從Kendo日曆的點擊事件中檢索日期?
- 4. 無法檢索事件商店日曆?
- 5. 檢索日曆事件條目信息
- 6. 檢索已刪除的日曆事件?
- 7. NSDate從日曆中檢索事件的問題
- 8. 如何從iPhone日曆中檢索所有事件?
- 9. 使用REST API從SharePoint日曆中檢索事件
- 10. Android從本地設備日曆中檢索事件
- 11. fullcalendar jQuery - 可以從Google日曆事件中檢索描述嗎?
- 12. 如何從多個谷歌日曆中高效檢索事件
- 13. 如何從我的iphone日曆中檢索事件?
- 14. 當從Google日曆中檢索事件時未呈現事件JSON編碼
- 15. 使用Zend_Gdata庫檢索Google日曆事件使用事件URL
- 16. 從谷歌日曆檢索事件使用PHP API脫機
- 17. 從HashMap中檢索位置
- 18. Zend Gdata日曆檢索日期範圍內的事件
- 19. IBM Domino檢索日期範圍的循環日曆事件
- 20. 日曆事件Reece日曆
- 21. 如何從事件日誌中檢索事件的消息?
- 22. 如何在PHP中創建事件後檢索Google日曆事件ID
- 23. 日曆在DateTimePicker控件中的位置
- 24. Primefaces日曆位置
- 25. 從android日曆中檢索最近添加的事件的數據
- 26. 從日曆中刪除所選事件
- 27. 從iPhone的日曆中刪除事件
- 28. Google日曆從每個日曆中獲取所有事件
- 29. 從日曆中獲取日曆事件(可能使用ActiveDirectory)
- 30. Google日曆從主日曆中獲取事件
沒有什麼新的我在eventkit框架看 – 2014-09-27 06:13:40
感謝Bhumit,地圖座標位置明顯與事件,所以我不知道它被存儲在哪裏? – 2014-09-27 06:57:02