/samples/MarkerMurder/Classes/FlipsideViewController.m
Objective C | 89 lines | 54 code | 23 blank | 12 comment | 0 complexity | 5838c2d9e0d867707fca6f8d33d07b69 MD5 | raw file
1// 2// FlipsideViewController.m 3// SampleMap : Diagnostic map 4// 5 6#import "FlipsideViewController.h" 7#import "MarkerMurderAppDelegate.h" 8 9 10@implementation FlipsideViewController 11 12@synthesize centerLatitude; 13@synthesize centerLongitude; 14@synthesize zoomLevel; 15@synthesize minZoom; 16@synthesize maxZoom; 17 18- (void)viewDidLoad { 19 [super viewDidLoad]; 20 21 self.view.backgroundColor = [UIColor groupTableViewBackgroundColor]; 22 23} 24 25 26/* 27 // Override to allow orientations other than the default portrait orientation. 28 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 29 // Return YES for supported orientations 30 return (interfaceOrientation == UIInterfaceOrientationPortrait); 31 } 32 */ 33 34 35- (void)didReceiveMemoryWarning { 36 RMLog(@"didReceiveMemoryWarning %@", self); 37 [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview 38 // Release anything that's not essential, such as cached data 39} 40 41- (void)viewDidAppear:(BOOL)animated { 42 43 CLLocationCoordinate2D mapCenter = [self.contents mapCenter]; 44 45 [centerLatitude setText:[NSString stringWithFormat:@"%f", mapCenter.latitude]]; 46 [centerLongitude setText:[NSString stringWithFormat:@"%f", mapCenter.longitude]]; 47 [zoomLevel setText:[NSString stringWithFormat:@"%.1f", self.contents.zoom]]; 48 [maxZoom setText:[NSString stringWithFormat:@"%.1f", self.contents.maxZoom]]; 49 [minZoom setText:[NSString stringWithFormat:@"%.1f", self.contents.minZoom]]; 50 51} 52 53- (void)viewWillDisappear:(BOOL)animated { 54 CLLocationCoordinate2D newMapCenter; 55 56 newMapCenter.latitude = [[centerLatitude text] doubleValue]; 57 newMapCenter.longitude = [[centerLongitude text] doubleValue]; 58 [self.contents moveToLatLong:newMapCenter]; 59 [self.contents setZoom:[[zoomLevel text] floatValue]]; 60 [self.contents setMaxZoom:[[maxZoom text] floatValue]]; 61 [self.contents setMinZoom:[[minZoom text] floatValue]]; 62} 63 64- (void)dealloc { 65 self.centerLatitude = nil; 66 self.centerLongitude = nil; 67 self.zoomLevel = nil; 68 self.minZoom = nil; 69 self.maxZoom = nil; 70 [super dealloc]; 71} 72 73- (RMMapContents *)contents 74{ 75 return [(MarkerMurderAppDelegate *)[[UIApplication sharedApplication] delegate] mapContents]; 76} 77 78- (IBAction)clearSharedNSURLCache 79{ 80 [[NSURLCache sharedURLCache] removeAllCachedResponses]; 81} 82 83- (IBAction)clearMapContentsCachedImages 84{ 85 [self.contents removeAllCachedImages]; 86} 87 88 89@end