Advertisement
Guest User

Untitled

a guest
Jun 1st, 2011
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1.  
  2. //
  3. // MapsController.m
  4. // TaskManager
  5. //
  6. // Created by xvorcak on 6/1/11.
  7. // Copyright 2011 __MyCompanyName__. All rights reserved.
  8. //
  9.  
  10. #import "MapsController.h"
  11.  
  12. @implementation MapsController
  13.  
  14. @synthesize mapView;
  15. @synthesize locationManager;
  16.  
  17. // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
  18. /*
  19. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  20. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  21. if (self) {
  22. // Custom initialization.
  23. }
  24. return self;
  25. }
  26. */
  27.  
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. locationManager = [[CLLocationManager alloc] init];
  31. locationManager.delegate = self;
  32. locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
  33. locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m
  34. [locationManager startUpdatingLocation];
  35. }
  36.  
  37. - (void)locationManager:(CLLocationManager *)manager
  38. didUpdateToLocation:(CLLocation *)newLocation
  39. fromLocation:(CLLocation *)oldLocation
  40. {
  41. NSLog(@"Did update location");
  42. CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(newLocation.coordinate.latitude, newLocation.coordinate.longitude);
  43. MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coord, 1000, 1000);
  44. [self.mapView setRegion:region animated:YES];
  45. }
  46.  
  47. /*
  48. // Override to allow orientations other than the default portrait orientation.
  49. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  50. // Return YES for supported orientations.
  51. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  52. }
  53. */
  54.  
  55. - (void)didReceiveMemoryWarning {
  56. // Releases the view if it doesn't have a superview.
  57. [super didReceiveMemoryWarning];
  58.  
  59. // Release any cached data, images, etc. that aren't in use.
  60. }
  61.  
  62. - (void)viewDidUnload {
  63. [super viewDidUnload];
  64. [locationManager stopUpdatingLocation];
  65. // Release any retained subviews of the main view.
  66. // e.g. self.myOutlet = nil;
  67. }
  68.  
  69.  
  70. - (void)dealloc {
  71. [super dealloc];
  72. }
  73.  
  74.  
  75. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement