【发布时间】:2013-05-30 02:42:44
【问题描述】:
在我的应用程序中,我想获取纬度和经度值。我有以下代码。它在第一次调用该函数时崩溃。应用程序询问用户使用当前位置的权限,并且应用程序崩溃抛出空引用异常,我将纬度值分配给字符串
string getLocation()
{
string latlong = "|";
CLLocationManager locationManager = new CLLocationManager();
locationManager.StartUpdatingLocation();
//var locationVar = locationManager.Location.Coordinate;
string lat = locationManager.Location.Coordinate.Latitude.ToString();
string lon = locationManager.Location.Coordinate.Longitude.ToString();
latlong = lat + "|" + lon;
return latlong;
}
【问题讨论】:
标签: xamarin.ios cllocationmanager latitude-longitude