我只是第一次以我的方式通过定位服务,所有的事情似乎都在工作,因为它正确地找到了我的位置,但是我在提取坐标时遇到了困难。
docs声明CLLocation有一个“坐标”属性,编译器对这段代码很满意。但是,在运行时,CLLocation似乎只返回一个字符串描述。
我启动了位置经理
_locationManager = new CLLocationManager ();
_locationManager.DesiredAccuracy = 1000;
// handle the updated location method and update the UI
_locationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
UpdateLocation (e.Locations [e.Locations.Length - 1], _destinationLatitude, _destinationLongitude);
};
if (CLLocationManager.LocationServicesEnabled)
_locationManager.StartUpdatingLocation ();事件正确触发。
static public void UpdateLocation (CLLocation current, Double destinationLat, Double destinationLng)
{
//Make the start pairing
string start = current.Coordinate.Latitude.ToString() + "," + current.Coordinate.Longitude.ToString();
//Make the destination pairing
string destination = destinationLat.ToString() + "," + destinationLng.ToString();
}然而,这个应用程序就崩溃了。在断点上捕捉到它,我看到下面的内容,它似乎只有一个包含的description属性。
Description "<+50.58198902,-3.67661728> +/- 65.00m (speed -1.00 mps / course -1.00) @ 25/07/2013 13:11:28 British…" string显然,我可以从这个文本字段中提取lat/lng,但我觉得我不需要这样做。任何帮助都很感激。

发布于 2013-07-29 07:50:51
我将完全相同的代码移到不同的控制器中,它工作得很好。两个控制器之间唯一的区别是,失败的控制器使用单调对话框反射api绑定屏幕元素。我不明白为什么这会有任何不同,但这是两个控制器之间唯一的区别。现在一切正常,如果我有时间的话,我会试着用一个更小的样本进行复制。
https://stackoverflow.com/questions/17857782
复制相似问题