setNeedsDisplayInMapRect doesn't trigger new drawMapRect: call

后端 未结 2 454
情歌与酒
情歌与酒 2020-12-16 21:18

I\'m using a custom MKOverlay/MKOverlayView to completely cover the Google basemap with my own tiles, which are loaded asynchronously. I follow the pattern of

2条回答
  •  天涯浪人
    2020-12-16 21:56

    The answer above did not work for me. From the NSLog printout I used I could see that a different thread was being used for despite grabbing the dispatch_get_current_queue() in canDrawMapRect and storing it for later use. This was the case in the iPad 4.3 Simulator at least, I did not attempt on the device.

    My solution was less satisfactory and more error prone solution of wait x time before calling.

    -(void)setNeedsDisplay:(WebRequest*)webRequest
    {  
       [webRequest retain];
       dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.25 * NSEC_PER_SEC), dispatch_get_main_queue(), 
       ^{
          [webRequest autorelease];
          [delegate setNeedsDisplayInMapRect:webRequest.request.requestedMapRect 
                                  zoomScale:webRequest.request.requestedScale];
       });     
    }
    

提交回复
热议问题