【发布时间】:2014-11-29 14:05:19
【问题描述】:
我已经更新到 Xcode 6(从 Xcode 5),现在我的应用程序不再工作了(我很自豪它在 IOS7 下工作)。我有这个“著名”的调试输出:
尝试在不提示位置授权的情况下启动 MapKit 位置更新。必须先调用 -[CLLocationManager requestWhenInUseAuthorization] 或 -[CLLocationManager requestAlwaysAuthorization]。
当然,我一直在谷歌搜索这条消息以找到解决方案,但似乎没有任何效果。所以我在征求你的意见。
这是我的头文件:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
#import "MapPoint.h"
#define kGOOGLE_API_KEY @"my google api"
#define kBgQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
@interface XYZViewController : UIViewController <MKMapViewDelegate, CLLocationManagerDelegate>
{
CLLocationManager *locationManager;
CLLocationCoordinate2D currentCentre;
int currenDist;
BOOL firstLaunch;
}
@property (weak, nonatomic) IBOutlet MKMapView *mapView;
@end
这是我的实现文件:
#import "XYZViewController.h"
#import "DetailViewController.h"
@interface XYZViewController ()
@end
@implementation XYZViewController
-(void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//Make this controller the delegate for the map view.
self.mapView.delegate = self;
// Ensure that you can view your own location in the map view.
[self.mapView setShowsUserLocation:YES];
//Instantiate a location object.
locationManager = [[CLLocationManager alloc] init];
//Make this controller the delegate for the location manager.
[locationManager setDelegate:self];
//Set some parameters for the location object.
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
firstLaunch=YES;
}
【问题讨论】:
标签: geolocation ios8 xcode6 core-location