Error displaying Map delegate method 'mapView: regionDidChange:' do not call

when using the map view at the same time in my MKMapKit application, the delegate method 'mapView: regionDidChange' does not call. This only happens when you drag the map. but when i increase or decrease it work. So its creation problem has to do with placing new annotations on the map when dragging the map. I am doing this code inmapView:regionDidChange:

int j=0;

-(void) mapView:(MKMapView *)mapsView regionDidChangeAnimated:(BOOL)animated{

    zoomLevel = self.mapView.region.span.latitudeDelta;

    if (![appDelegate internetConnected]){
        return;
    }

    if (appDelegate.isMapViewRegionChanged) {
        if (j==0) {
            j++;
            return;
        }else{
            j=0;
            appDelegate.isMapViewRegionChanged  = FALSE;
            return;
        }
    }
    [self callGetMapViewWithObject:nil];
}


/*
first boolean is to check Internet connection.

[appDelegate internetConnected]

Second condition is to return when we navigate from any view controller too map View controller.

appDelegate.isMapViewRegionChanged

Third is a method to place new annotations. 

[self callGetMapViewWithObject:nil]; 

*/

      

I have checked all conditions and boolean, but my encoding is not the cause of this error. so may be due to the fact that it is due to a change in the region.

So when using my app with a map, 20% of the time it behaves like an Ideal (the method does not call).

can someone help me on this.

Thanks in advance.

+3


source to share


1 answer


EDIT . This broke randomly, so now I call the function again (canceling what I said below), no further changes ... and um, it works. I feel like I'm flipping a coin.

I just happened to do this because I have a subclass MKMapView. I don't know if you are subclassing this or not, but somehow Apple superfunctions like: - (void) scrollViewDidScroll; called super but was not intercepted properly and missed this call.

When I removed the "overridden" call, it was just a call to [super scrollView], it started working correctly.



I don't know why apple's code is broken this way (calling super doesn't have the same effect that it doesn't override it), but make sure you don't subclass them: ScrollView functions MKMapView functions ... or perhaps with a gesture recognizer WildCard provided very kindly for the answer to why Map Views don't respond to touchhesBegan / Moved etc. here: How to intercept touch events of MKMapView or UIWebView objects? ...

If that doesn't help, make sure you don't have a view on top of other views, incorrect delegates, xibs are ordered and connected, the usual stuff.

0


source







All Articles