0

How can I open a view when I clicked on annotation's button with a navigation button to go back to my mapkit and pass some parameters to the view?

Regards

DeZigny
  • 1,953
  • 4
  • 19
  • 29
  • Navigate to another view just like you would anywhere. There's nothing particular about moving from a view that includes a mkmapview. – Nick Jun 12 '11 at 21:23

2 Answers2

2

I have found a solution. Inside:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation

Add:

UIButton *btn = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[btn addTarget:self action:@selector(pinTouched:) forControlEvents:UIControlEventTouchUpInside];

Then have a function to open the desired view:

-(void)pinTouched:(UIButton *)sender
{
myView.transform  = CGAffineTransformMakeScale(.01, .01);
[self.view addSubview:myView];
}
DeZigny
  • 1,953
  • 4
  • 19
  • 29
0

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation {

... ... ...

//important

//otherwise calloutAccessoryControlTapped not called

pin.canShowCallout = YES;

pin.calloutOffset = CGPointMake(-10, -10);

UIImageView *leftIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"some.png"]];

leftIconView.backgroundColor = [UIColor clearColor];

leftIconView.contentMode = UIViewContentModeScaleAspectFit;

leftIconView.frame = CGRectMake(0, 0, 40, 40);

pin.leftCalloutAccessoryView = leftIconView;

....

....

return pin;

}

-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {

// annotation tapped

float viewWidth = 100;

float viewHeight = 300;

float viewX = 50;

float viewY = 50;

CGRect viewRect = CGRectMake(viewX,viewY, viewWidth, viewHeight);

UIView *viewSub = [[UIView alloc] initWithFrame:viewRect];

viewSub.backgroundColor = [UIColor redColor];

viewSub.tag = 666;

[self.view addSubview:viewSub];

[self.view bringSubviewToFront:viewSub];

}

Add080bbA
  • 1,818
  • 1
  • 18
  • 25