0

Apologies if this is a basic question but I am new to Xcode and have a storyboard app and in the storyboard (with no segue) I have a view controller with an embedded map view.

On the storyboard screen I have an image with a tap gesture linked, I have tested the tap and it works (NSLog) but I want to know how to launch my mapview view controller and also zoom to an x&y.

My code currently has

-(IBAction)handleMapTap:(UIGestureRecognizer *)sender {   
    NSLog(@"Tapped");  
 }

& I have tried;

MMMapViewController *mapViewController = [[MMMapViewController alloc] initWithNibName:@"MapView" bundle:nil];
[self.navigationController pushViewController:mapViewController animated:YES];

My view controller has a class set as MMMapViewController I have given the view controller a storyboard id of MapView (if it's required?).

I've read a lot of stackoverflow articles but can't seem to find an answer. If anyone can help I would be really grateful.

1 Answer 1

0
-(IBAction)handleMapTap:(UIGestureRecognizer *)sender 
{
    MMMapViewController *mapViewController = [[MMMapViewController alloc] initWithNibName:@"MapView" bundle:nil];
    //[self.navigationController pushViewController:mapViewController animated:YES];
     [self presentModalViewController:mapViewController animated:YES];
    [mapViewController release];
}

It would probably help to know what self is, if it is indeed a UIViewController, then I would make sure that self.navigationController is not nil. You actually have the right code, as far as I can tell, but depending on your scenario, you could get away with presenting the mapView as a modal view controller.

1
  • Thank you, I carried on playing and worked out how to segue across to the map view, what I now need to do is to zoom in on the a defined location, but that's tomorrows task! Thanks again. Feb 25, 2013 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.