0
1。我正在使用的MKMapView多針,我想在挖掘管腳的下一個視圖中顯示詳細如何切換到iPhone SDK中的MKMapView中的註釋針點擊另一個視圖?
#import "mapViewController.h"
#import "displaymap.h"
#import "second.h"
@implementation mapViewController
@synthesize mapview;
@synthesize selectedAnnotationsl;
- (void)viewDidLoad {
[super viewDidLoad];
[mapview setMapType:MKMapTypeStandard];
[mapview setZoomEnabled:YES];
[mapview setScrollEnabled:YES];
MKCoordinateRegion region={{0.0,0.0},{0.0,0.0}};
region.center.latitude=22.292189;
region.center.longitude=70.792207;
region.span.longitudeDelta=0.01f;
region.span.latitudeDelta=0.01f;
[mapview setRegion:region animated:YES];
//[mapview setDelegate:self];
displaymap *ann=[[displaymap alloc]init];
[email protected]"alpesh";
[email protected]"Mahatma Gandhi";
ann.coordinate = region.center;
[mapview addAnnotation:ann];
region.center.latitude=22.295031;
region.center.longitude=70.790837;
region.span.longitudeDelta=0.01f;
region.span.latitudeDelta=0.01f;
displaymap *bnn=[[displaymap alloc]init];
[email protected]"samir";
[email protected]"Mahatma Gandhi";
bnn.coordinate = region.center;
[mapview addAnnotation:bnn];
//selectedAnnotationsl =[[NSArray alloc]initWithObjects:bnn.title,ann.title,nil];
}
-(MKAnnotationView *)mapview:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation
{
MKPinAnnotationView *pinView=nil;
if(annotation != mapview.userLocation)
{
static NSString *defaultPinID = @"com.invasivecode.pin";
pinView=(MKPinAnnotationView *)[mapview dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if(pinView==nil)pinView=[[[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:defaultPinID]autorelease];
pinView.pinColor=MKPinAnnotationColorRed;
pinView.canShowCallout=YES;
pinView.animatesDrop=YES;
pinView.calloutOffset= CGPointMake(-5, 5);
}
else
{
[mapview.userLocation setTitle:@"I am here"];
}
return pinView;
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
MKPinAnnotationView *annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
UIButton *addButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[addButton addTarget:self action:@selector(changepage:) forControlEvents:UIControlEventTouchUpInside];
[annView setPinColor:MKPinAnnotationColorRed];
annView.rightCalloutAccessoryView = addButton;
annView.animatesDrop = TRUE;
annView.canShowCallout = YES;
return annView;
}
-(IBAction)changepage:(UIView*)sender
{
second *s = [[second alloc]initWithNibName:@"second" bundle:nil];
s.title = @"samir";
[[self navigationController] pushViewController:s animated:YES];
}
@Samir,你已經解決了這個問題?如何? – EmptyStack 2011-06-28 12:32:49
是我使用annotation解決了這個問題。標題 描述* d = [[Description alloc] initWithNibName:@「Description」bundle:nil]; \t \t d.title = view.annotation.title; \t \t [self.navigationController pushViewController:d animated:YES]; – Samir 2011-07-05 12:48:35