background image

27

    

return

  self;

28

}

29

- (

void

)dealloc

30

{

31

    self.locationManager = nil;

32

    [super dealloc];

33

}

34

- (

void

)viewDidLoad

35

{

36

    [super viewDidLoad];

37

    

// Do any additional setup after loading the view, typically from a nib.

38

    

//delegate

39

    self.locationManager.delegate = self;

40

    

//The desired location accuracy.

41

    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;

42

    

//Specifies the minimum update distance in meters.

43

    self.locationManager.distanceFilter = kCLDistanceFilterNone;

44

    self.locationManager.purpose =

45

    @"To provide functionality based on user's current location.";

46

    [self.locationManager startUpdatingLocation];

47

     

48

}

49

 

50

 

51

(

void

)locationManager:(CLLocationManager 

*)manager 

didChangeAuthorizationStatus:

(CLAuthorizationStatus)status

52

{

53

    NSLog(@"didChangeAuthorizationStatus---%u",status);

54

     

55

 

56

}

57

 

58

- (

void

)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error

59

{

60

    NSLog(@"didChangeAuthorizationStatus----%@",error);

61

 

62

}

63

 

64

(

void

)locationManager:(CLLocationManager 

*)manager 

didUpdateToLocation:(CLLocation 

*)newLocation fromLocation:(CLLocation *)oldLocation

65

{

66

     

67

       UIAlertView*  av  =  [[UIAlertView  alloc]  initWithTitle:@"update"  message:[NSString 
stringWithFormat:@"didUpdateToLocation:   newLocation:  %@   old:%@",newLocation,oldLocation] 
delegate:nil cancelButtonTitle:@"cancel" otherButtonTitles:@"ok", nil];

68

    [av show];

69

    [av release];

70

 

71

   

// NSLog(@"didUpdateToLocation:  newLocation: %@",newLocation);

72

}

73

 

74

 

75

- (

void

)didReceiveMemoryWarning

76

{

77

    [super didReceiveMemoryWarning];

78

    

// Dispose of any resources that can be recreated.

79

}

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

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