Note that there are some explanatory texts on larger screens.

plurals
  1. PO- (MKAnnotationView *)mapView not getting called
    text
    copied!<p>In my code, the <code>- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id &lt;MKAnnotation&gt;)annotation</code> method is not getting called. I don know why. Can anyone please help me?</p> <p>Below is my code:</p> <pre><code>- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id &lt;MKAnnotation&gt;)annotation { MKPinAnnotationView *pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@","]; NSLog(@"pin map"); if(pinView == nil) { pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@""]; pinView.animatesDrop = YES; pinView.canShowCallout = YES; UIImage *image = [UIImage imageNamed:@"ann.png"]; CGRect resizeRect; resizeRect.size = image.size; CGSize maxSize = CGRectInset(self.view.bounds, [map annotationPadding], [map annotationPadding]).size;*/ maxSize.height -= self.navigationController.navigationBar.frame.size.height + [map calloutHeight]; if (resizeRect.size.width &gt; maxSize.width) resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height / resizeRect.size.width * maxSize.width); if (resizeRect.size.height &gt; maxSize.height) resizeRect.size = CGSizeMake(resizeRect.size.width / resizeRect.size.height * maxSize.height, maxSize.height); resizeRect.origin = (CGPoint){0.0f, 0.0f}; UIGraphicsBeginImageContext(resizeRect.size); [image drawInRect:resizeRect]; UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); pinView.image = resizedImage; pinView.opaque = NO; UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; [rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside]; pinView.rightCalloutAccessoryView = rightButton; if (annotation == mapView.userLocation) { return nil; } return pinView; } else { pinView.annotation = annotation; } return pinView; } </code></pre> <p>This is how I am adding the annotations to the map:</p> <pre><code>-(void) Annotations:(int)i { /*NSString* address = [mpartyDetail objectAtIndex:i]; address = [[address componentsSeparatedByCharactersInSet: [NSCharacterSet whitespaceCharacterSet]] componentsJoinedByString: @""]; NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&amp;output=csv", address]; NSLog(@"nsstring %@",urlString); NSString *locationString = [[[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:urlString]] autorelease]; NSLog(@"location string %@",locationString); NSArray *latlng = [locationString componentsSeparatedByString:@","]; NSLog(@"the latlng %@",latlng); float lat = [[latlng objectAtIndex:2] floatValue]; float lng = [[latlng objectAtIndex:3] floatValue]; */ NSLog(@"ann"); lat = [[latiArray objectAtIndex:i]floatValue]; lng = [[longiArray objectAtIndex:i]floatValue]; CLLocationCoordinate2D newCoord = {lat,lng}; mapAnnotations* annotation = [[mapAnnotations alloc] initWithCoordinate:newCoord]; [mapView addAnnotation:annotation]; } </code></pre> <p>mapAnnotations is another class. The below code shows the method of that class which is getting called:</p> <pre><code>- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate{ NSLog(@"the cor"); self = [super init]; if (self != nil) { NSLog(@"in"); _coordinate = coordinate; } return self; } </code></pre> <p>The idea is that I add annotations when the user presses on the map and the user can give any title to that pin. I need a callout to show the title entered by the user. The annotations are getting added. But I am not able to get the callout as this method is not getting called.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload