From 326d6430689a0a3491c82777241555dceb451fbe Mon Sep 17 00:00:00 2001 From: Xiaomin Date: Fri, 25 May 2018 18:59:23 +0800 Subject: [PATCH 1/2] [Weex-410][iOS] Fix gesture related crash on iOS8 --- ios/sdk/WeexSDK/Sources/Model/WXComponent.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm b/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm index 0cf24fab6a..b3033a457c 100644 --- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm +++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm @@ -238,6 +238,9 @@ - (void)dealloc if (_panGesture) { [_panGesture removeTarget:nil action:NULL]; } + if ([[[UIDevice currentDevice] systemVersion] floatValue] < 9.0) { + [self _removeAllEvents]; + } if (_positionType == WXPositionTypeFixed) { [self.weexInstance.componentManager removeFixedComponent:self]; From a6b751a2f69a4f213e771d8f1f66701a2cce5975 Mon Sep 17 00:00:00 2001 From: Xiaomin Date: Mon, 28 May 2018 14:25:11 +0800 Subject: [PATCH 2/2] [Weex-410][iOS] Add ext config removeEventsOfWXComponentWhenDealloc for fix --- ios/sdk/WeexSDK/Sources/Model/WXComponent.mm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm b/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm index b3033a457c..4c52f518a2 100644 --- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm +++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm @@ -40,10 +40,14 @@ #import "WXTracingManager.h" #import "WXComponent+Events.h" #import "WXComponent+Layout.h" +#import "WXConfigCenterProtocol.h" +#import "WXSDKEngine.h" #pragma clang diagnostic ignored "-Wincomplete-implementation" #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation" +static BOOL bInited = NO; +static BOOL bNeedRemoveEvents = YES; @interface WXComponent () @end @@ -148,7 +152,13 @@ - (instancetype)initWithRef:(NSString *)ref [self _initViewPropertyWithStyles:_styles]; [self _initCompositingAttribute:_attributes]; [self _handleBorders:styles isUpdating:NO]; - + if (!bInited) { + id configCenter = [WXSDKEngine handlerForProtocol:@protocol(WXConfigCenterProtocol)]; + if ([configCenter respondsToSelector:@selector(configForKey:defaultValue:isDefault:)]) { + bNeedRemoveEvents = [[configCenter configForKey:@"iOS_weex_ext_config.removeEventsOfWXComponentWhenDealloc" defaultValue:@(YES) isDefault:NULL] boolValue]; + bInited = YES; + } + } } return self; @@ -238,8 +248,10 @@ - (void)dealloc if (_panGesture) { [_panGesture removeTarget:nil action:NULL]; } - if ([[[UIDevice currentDevice] systemVersion] floatValue] < 9.0) { - [self _removeAllEvents]; + if (bNeedRemoveEvents) { + if (WX_SYS_VERSION_LESS_THAN(@"9.0")) { + [self _removeAllEvents]; + } } if (_positionType == WXPositionTypeFixed) {