【发布时间】:2014-09-18 10:34:05
【问题描述】:
我刚开始我的 iOS 8 项目,我也遇到了我无法弹出问题以获得许可的问题。我在 info.plist 中添加了以下内容
<key>NSLocationWhenInUseUsageDescription</key>
<string>The spirit of stack overflow is coders helping coders</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>I have learned more on stack overflow than anything else</string>
这是我的代码:
@interface ViewController () <MKMapViewDelegate>
@property (nonatomic, strong) UIPopoverController* userDataPopover;
@property (weak, nonatomic) IBOutlet MKMapView *mapView;
@property (strong, nonatomic, retain) CLLocationManager *locationManager;
@end
@implementation ViewController
-(CLLocationManager *)locationManager
{
if(!_locationManager) _locationManager = [[CLLocationManager alloc]init];
return _locationManager;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.mapView.delegate = self;
[self.locationManager requestWhenInUseAuthorization];
//[self.locationManager requestAlwaysAuthorization];
[self.locationManager startUpdatingLocation];
self.mapView.showsUserLocation = YES;
[self.mapView showsUserLocation];
[self.mapView setMapType:MKMapTypeStandard];
[self.mapView setZoomEnabled:YES];
[self.mapView setScrollEnabled:YES];
}
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 800, 800);
[self.mapView setRegion:[self.mapView regionThatFits:region] animated:YES];
}
【问题讨论】:
-
iOS8 中的整个位置都破坏了我的应用程序。在 iOS7 中工作正常,现在有了权限更改,一切都被打破了。将密切关注这一点。
-
我在我的代码中找到了解决方案。当我忽略这一行时:[self.locationManager startUpdatingLocation];一切都开始工作了!希望对你有帮助!
-
为您的 plist 中的精彩文字点赞!