Reputation: 1867
Whenever the user moves my MKMapView, I load more pins on to the map. Right now, I am using this code to detect when they drag it:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
- (void)didDragMap:(UIGestureRecognizer*)gestureRecognizer {
if (gestureRecognizer.state == UIGestureRecognizerStateEnded){
CLLocationCoordinate2D topLeft, bottomRight;
topLeft = [self.mapView convertPoint:CGPointMake(0, 0) toCoordinateFromView:self.mapView];
CGPoint pointBottomRight = CGPointMake(self.mapView.frame.size.width, self.mapView.frame.size.height);
bottomRight = [self.mapView convertPoint:pointBottomRight toCoordinateFromView:self.mapView];
[self loadMorePlaces:topLeft bottomRight:bottomRight];
}
}
However, this only detects when a user stopped dragging. A user can "fling" the map and the map can still be moving AFTER they finish "dragging". Is there a way I can find when the map stops moving? Thanks
Upvotes: 3
Views: 1169