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