Firstly I would say that the authors have done a commendable job with this Book.
Coming back to the topic, below is how I implemented my third tab for Map challenge.
@interface MapViewController : UIViewController
IBOutlet MKMapView *mv;
self = [super initWithNibName:nil bundle:nil];
UITabBarItem *tb3 = [self tabBarItem]; [tb3 setTitle:@"Map"]; UIImage *tb3i = [UIImage imageNamed:@"rsz_maps.png"]; [tb3 setImage:tb3i]; } return self;
-(id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle
return [self init];
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
CLLocationCoordinate2D loc = [userLocation coordinate];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, 250, 250);
[mv setRegion:region animated:YES];
if ([mv delegate] == self)
Now my xib file is named MapViewController.xib
I have set the view property to MKMapView and my instance map variable ‘mv’ is also set to MKMapview
Is this the correct approach?
I have a feeling I have some redundancy in my code as I have two pointers to the same MKMapView.
Could I replace ‘mv’ (when I have sent it messages) with MapViewController’s view property as they both point to MKMapView?
Any help would be appreciated.
Thanks once again!