2010-04-17 60 views

回答

4

您可以实现像这样的方法:

-(void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated 
{ 
    NSNumber *animatedNumber = [NSNumber numberWithBool:animated]; 
    NSArray *args = [[NSArray alloc] initWithObjects:mapView, 
                animatedNumber,nil]; 

    [self performSelector:@selector(delayedMapViewRegionDidChangeAnimated:) 
      withObject:args 
      afterDelay:2.0f]; 

    [args release]; 
} 

然后,在同一类的地方:

-(void)delayedMapViewRegionDidChangeAnimated:(NSArray *)args 
{ 
    MKMapView *mapView = [args objectAtIndex:0]; 
    BOOL animated = [[args objectAtIndex:1] boolValue]; 

    // do what you would have done in mapView:regionDidChangeAnimated: here 
} 

当然,如果你不需要的那些论据之一(无论是mapView或者animated),只要通过你需要的那个,你就可以使这变得相当简单。

如果你不能只编辑MKMapViewDelegate的代码,也许你可以做类似的方法调整,但你真的真的 hacky。

+0

感谢男士的帮助 – Nanz 2010-04-22 13:22:34

0

您可以发送performSelector:withObject:afterDelay:或其相关方法之一的延迟信息。