2011-05-10 11 views
5

मैं पिन आईडी के पिन आईडी (यानी पिन शीर्षक और उपशीर्षक का विवरण) कैसे ढूंढ सकता हूं?मानचित्र एनोटेशन व्यू में पिन आईडी कैसे ढूंढें?

मेरे पास पिन एनोटेशन दिखाने के लिए यह है।

[resultCoordinate addObjectsFromArray:[sqlClass return_Coordinate]]; 

if ([resultCoordinate count]) 
{ 
    for (int i =0; i < [resultCoordinate count]; i++) 
    { 
     dict = [resultCoordinate objectAtIndex:i]; 

     MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } }; 
     region.center.latitude = [[dict objectForKey:@"Lati"] floatValue]; 
     region.center.longitude = [[dict objectForKey:@"Longi"] floatValue]; 
     region.span.longitudeDelta = 0.2f; 
     region.span.latitudeDelta = 0.2f; 

     NSString *fishName = [dict objectForKey:@"Fish"]; 
     fishName = [fishName stringByAppendingString:@" "]; 

     NSString *fishWeight = [dict objectForKey:@"Weight"]; 
     fishWeight = [fishWeight stringByAppendingString:@" kg"]; 


     fishName = [fishName stringByAppendingString:fishWeight]; 

     MapAnnotation *ann = [[MapAnnotation alloc] init]; 

     ann.title = fishName; 
     ann.subtitle = [dict objectForKey:@"DateTime"]; 

     ann.coordinate = region.center; 
     [mapView addAnnotation:ann]; 
    } 
} 

और प्रतिनिधि में:: इस कोड में दृश्य लोड किया है

- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation 
{ 
    MKPinAnnotationView *pinView = nil; 

    static NSString *defaultPinID = @"com.invasivecode.pin"; 
    pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID]; 
    if (pinView == nil) 
    pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease]; 
    pinView.pinColor = MKPinAnnotationColorPurple; 
    pinView.canShowCallout = YES; 
    pinView.animatesDrop = YES; 

    UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
    [infoButton addTarget:self action:@selector(infoButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; 
    pinView.rightCalloutAccessoryView = infoButton; 
    [defaultPinID release]; 

    return pinView; 
} 

और जानकारी बटन पर क्लिक करें पर:

-(void)infoButtonPressed:(id)sender 
{ 
    recordCatch = [[RecordCatchDetails alloc] initWithNibName:@"RecordCatchDetails" bundle:nil]; 
    [self.view addSubview:recordCatch.view] ; 
} 

कहाँ रिकॉर्ड पकड़ नया वर्ग वस्तु है।

उत्तर

4

जब एनोटेशन का चयन किया जाता है तो नक्शा व्यू mapView:didSelectAnnotationView: अपने प्रतिनिधि में विधि को कॉल करता है, तो आप इसे प्राप्त करने के लिए इसे ओवरराइड कर सकते हैं।

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view 
{ 
MKAnnotation *selectedAnnotation = view.annotation // This will give the annotation. 
if([selectedAnnotation.title isEqualToString:@"yourTitle"]) 
{ 
    // Do something 
} 
} 

आप गौण नियंत्रण क्लिक के लिए कार्रवाई प्राप्त करना चाहते हैं

-(void)mapView:(MKMapView *)mapView annotationView:(MKPinAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { 
// get annotation details here. 
} 
+0

के उपयोग मुझे और अधिक विशिष्ट करते हैं। मेरे पास 3 पिन हैं जिनमें शीर्षक और उपशीर्षक है। मुझे पहले चुनने दो। फिर एनोटेशन शीर्षक के साथ जानकारी है। मैं उस पिन से संबंधित सभी डेटा दिखाने के लिए जानकारी बटन पर क्लिक करना चाहता हूं। और यह डेटा दिखाने के लिए एक नई कक्षा को कॉल करेगा। मुझे बताएं कि डेटाबेस से नई कक्षा में सभी डेटा दिखाने के लिए हम पिन और उसके उपशीर्षक का पता कैसे लगाएंगे। –

+0

आपको एनोटेशन मिलेगा जो आपको इसके विवरण प्रदान कर सकता है, फिर आप इसे किसी शब्दकोश में नए व्यू या स्टोर में भेज सकते हैं और फिर इसे पास कर सकते हैं। – visakh7

+0

लेकिन शीर्षक गतिशील साधन डेटाबेस से आता है। तो मानचित्र में बहुत सारे पिन होने पर मैं शीर्षक की तुलना कैसे कर सकता हूं। –

संबंधित मुद्दे