IOS GPS 定位

1、添加引用Corelocation.framkwork

2、  .h文件添加   #import <CoreLocation/CoreLocation.h>

@interface ViewController : UIViewController
{
    CLLocationManager *locationManger;
   
}

3.m文件添加

    locationManger =[[CLLocationManager alloc]init];
    [locationManger setDelegate:self];
   
    [locationManger setDistanceFilter:kCLDistanceFilterNone];
    [locationManger setDesiredAccuracy:kCLLocationAccuracyBest];
    [locationManger startUpdatingLocation];

 

 

 

 

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    NSLog(@"location:%@",newLocation);
   
}

-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
    NSLog(@"error:%@",error);
}

 

 

posted @ 2012-10-15 14:28  銱ル╬鎯噹  阅读(555)  评论(0编辑  收藏  举报