用户位置在 iOS 8 中不起作用User Location not working in iOS 8

在文本编辑器中:打开 info.plist,并添加以下内容:Within a text editor: Open up your Info.plist and add the following:

<key>NSLocationWhenInUseUsageDescription</key>
<string>You are about to use location!</string>

<key>NSLocationAlwaysUsageDescription</key>
<string>This will be called if location is used behind the scenes</string>

在 MainViewController.cs 中,需要调用以下内容:And within the MainViewController.cs you need to call the following:

iPhoneLocationManager.RequestWhenInUseAuthorization ();

例如EX:

if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
    iPhoneLocationManager.RequestWhenInUseAuthorization ();
    iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
        UpdateLocation (mainScreen, e.Locations [e.Locations.Length - 1]);
        };
} else {
    // this won't be called on iOS 6 (deprecated)
    iPhoneLocationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => {
        UpdateLocation (mainScreen, e.NewLocation);
        };
}