2011-06-09 78 views
0

如何在打開視圖時單擊帶導航按鈕的註釋按鈕以返回到我的mapkit並將某些參數傳遞給視圖?當calloutAccessoryControlTapped觸發時打開視圖

Regards

+0

請幫傢伙 – DeZigny 2011-06-10 09:50:33

+0

導航到另一個視圖,就像你在任何地方。從包含mkmapview的視圖移動沒有什麼特別的。 – Nick 2011-06-12 21:23:24

回答

2

我找到了解決辦法。內部:

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

地址:

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

然後有一個函數打開所需的視圖:

-(void)pinTouched:(UIButton *)sender 
{ 
myView.transform = CGAffineTransformMakeScale(.01, .01); 
[self.view addSubview:myView]; 
} 
0

- (MKAnnotationView *)的MapView:(*的MKMapView)的MapView viewForAnnotation :(id)註釋{

... ... ...

//重要

//否則calloutAccessoryControlTapped不叫

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;

}

- (無效)的MapView:(的MKMapView *)的MapView annotationView:(MKAnnotationView *)視圖calloutAccessoryControlTapped:(UIControl *)控制{

//註釋抽頭

浮子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];

}

相關問題