OMG! I didn't know I could make such "silly" mistake.
Yes, the sentence in question The same code works fine on an iPhone. I was getting error CALayer position contains NaN
because in my custom - (AnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id ) annotation
method, where I am calculating
annotationView.layer.anchorPoint = CGPointMake(0.5, 1.0 - (diffFromBottom * 1.0)/annotationView.image.size.height);
annotationView.image was blank because I forgot to add the pin image in iPad project. It was there in iPhone code. So it was divided by Zero (0) and cause an error.
I put break point, and print with NSLog
get to know that,
1.0 - (diffFromBottom * 1.0)/annotationView.image.size.height
the value of this was printed, -inf
. This was causing the app crash.
Basically, this error occurs if you'll perform a division by infinity or zero so whenever you got such error first look in code, where you performing the division operation.