iOS定位和位置信息获取

2016-11-16  本文已影响36人  欲速则不达

定位和反查位置信息要加载两个动态库 CoreLocation.framework 和 MapKit.framework 一个获取坐标一个提供反查,可以通过配置NSLocationAlwaysUsageDescription或者 NSLocationWhenInUseUsageDescription来告诉用户使用定位服务的目的,并且注意这个配置是必须的

import "ViewController.h"

import <UIKit/UIKit.h>

import <CoreLocation/CoreLocation.h>

import <MapKit/MapKit.h>

@interface ViewController ()<CLLocationManagerDelegate>

@property (nonatomic, strong) CLLocationManager *locationManager;
@property (nonatomic, strong) UIButton *button;

@end

@implementation ViewController

实现locationManager的代理方法

上一篇 下一篇

猜你喜欢

热点阅读