我安装了XCODE 6版本表单developer.apple(我认为是最后一个)并且我在那里工作(iOS 7项目)但显然带来iOS 8 SDK我真的不知道这是否影响了项目
我有一个mapview,我想显示用户位置,但这是不可能的! 代码:
@property (nonatomic, strong) CLLocationManager *manager;
- (void)viewDidLoad {
[super viewDidLoad];
[self.manager requestAlwaysAuthorization];
[self.manager requestWhenInUseAuthorization];
[self.mapview setDelegate:self];
self.mapview.showsUserLocation = YES;
[self.mapview setCenterCoordinate:self.mapview.userLocation.location.coordinate animated:YES];
}
我没有让应用程序使用您当前的位置...",mapview显示非洲的某个地方没有别针或任何东西。
答案 0 :(得分:0)
您必须初始化/分配CLLocationManager *manager
类似的东西:
// Create the core location manager object
_locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
// for iOS 8, specific user level permission is required,
// "when-in-use" authorization grants access to the user's location
//
// important: be sure to include NSLocationWhenInUseUsageDescription along with its
// explanation string in your Info.plist or startUpdatingLocation will not work.
//
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];