Q: MKAnnotation pin image doesn't change when scroll I write code to change mkannotation pin image when scroll to page.... but I'll
test it cannot change this is my code
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{
int pageNum = (int)(self.scroll.contentOffset.x / self.scroll.frame.size.width);
if(pageNum==0){
    if([[annotation title]isEqualToString:@"place1"]){
    myPin = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"place"];
    myPin =[[MKAnnotationView alloc]
            initWithAnnotation:annotation reuseIdentifier:@"place"];
    myPin.image = [UIImage imageNamed:@"star.png"];
    }
}
else if (pageNum==1){
    if([[annotation title]isEqualToString:@"place2"]){
        myPin = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"place"];
        myPin =[[MKAnnotationView alloc]
                initWithAnnotation:annotation reuseIdentifier:@"place"];
        myPin.image = [UIImage imageNamed:@"star.png"];
    }
}
else if (pageNum==3){
    if([[annotation title]isEqualToString:@"place3"]){
    myPin = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"place"];
    myPin =[[MKAnnotationView alloc]
            initWithAnnotation:annotation reuseIdentifier:@"place"];
    myPin.image = [UIImage imageNamed:@"star.png"];
    }
}
}


A: If I am reading your question correctly it seems like you have a view controller with a scroll view in it, and you want markers on the map (or maps) to be customized based on which 'page' of the scroll view is currently showing.
I'm guessing that code won't work because you don't really have any control over when those annotation views are created; MapKit just calls the method whenever it needs a view. (I am assuming that you know that the code above uses the same pin image for all three of the pages, and that you didn't cover the pageNum==2 case.)
I think a better approach might be to figure out when the scroll view has moved to a new 'page' and at that point remove and re-add different annotations so they'll have the appearance you want. It's hard to give a better answer because I can't really imagine the layout you're working with.
