background image

IOS 地图开发实例解析

CLLocationManager 位 置 定 位 :

首先,如标题,先定位吧。

    第一步,新建一个 singleView 的空白工程,如果新建,这里不做赘述了。

   第二步:因为地图开发相关的 framework:MapKit.framework、CoreLocation.framework,

 

至于如何添加,一般的

ios 相关博客都是有介绍。

   在主界面的控制器

ViewController.h 文件中,我们啥也不做,.m 文件中,我们需声明一个

CLLocationManager* locationManager 的属性,我们让其实现

CLLocationManagerDelegate 的

协议,并覆写其更新位置的方法,如下:

01

//

02

//  ViewController.m

03

//  LBS_001_CLLocationManager

04

//

05

//  Created by liqun on 13-7-17.

06

//  Copyright (c) 2013 年 Block Cheng. All rights reserved.

07

//

08

 

09

#import "ViewController.h"

10

#import <CoreLocation/CoreLocation.h>

11

@interface ViewController ()<CLLocationManagerDelegate>{

12

 

13

  

14

}

15

@property (nonatomic,retain)CLLocationManager* locationManager;

16

@end

17

 

18

@implementation ViewController

19

 

20

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

21

{

22

    

if

 (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {

23

        NSLog(@"nibName:  %@   bundle: %@",nibBundleOrNil,nibBundleOrNil);

24

        _locationManager = [[CLLocationManager alloc] init];

25

    }

26

 

                   找软件资料,就到一览软件文库

http://wk.yl1001.com/rj/