[ReactNative] Fix RCTMapManager retaining cycle

This commit is contained in:
Tadeu Zagallo 2015-03-13 09:10:57 -07:00
parent 6299803081
commit e714ba15a5
2 changed files with 7 additions and 15 deletions

View File

@ -2,6 +2,7 @@
#import "RCTMap.h"
#import "RCTConvert.h"
#import "RCTEventDispatcher.h"
#import "RCTLog.h"
#import "RCTUtils.h"
@ -90,18 +91,9 @@ const CGFloat RCTMapZoomBoundBuffer = 0.01;
{
if (region) {
MKCoordinateRegion coordinateRegion = self.region;
if ([region[@"latitude"] isKindOfClass:[NSNumber class]]) {
coordinateRegion.center.latitude = [region[@"latitude"] doubleValue];
} else {
RCTLogError(@"region must include numeric latitude, got: %@", region);
return;
}
if ([region[@"longitude"] isKindOfClass:[NSNumber class]]) {
coordinateRegion.center.longitude = [region[@"longitude"] doubleValue];
} else {
RCTLogError(@"region must include numeric longitude, got: %@", region);
return;
}
coordinateRegion.center.latitude = [RCTConvert double:region[@"latitude"]];
coordinateRegion.center.longitude = [RCTConvert double:region[@"longitude"]];
if ([region[@"latitudeDelta"] isKindOfClass:[NSNumber class]]) {
coordinateRegion.span.latitudeDelta = [region[@"latitudeDelta"] doubleValue];
}

View File

@ -60,11 +60,11 @@ RCT_REMAP_VIEW_PROPERTY(region, JSONRegion)
- (void)mapView:(RCTMap *)mapView regionDidChangeAnimated:(BOOL)animated
{
[self _regionChanged:mapView];
[self _emitRegionChangeEvent:mapView continuous:NO];
[mapView.regionChangeObserveTimer invalidate];
mapView.regionChangeObserveTimer = nil;
[self _regionChanged:mapView];
[self _emitRegionChangeEvent:mapView continuous:NO];
}
#pragma mark Private