// // RNNSwizzles.m // ReactNativeNavigation // // Created by Leo Natan (Wix) on 1/17/18. // Copyright © 2018 artal. All rights reserved. // #import "RNNSwizzles.h" @import ObjectiveC; @import UIKit; @implementation RNNSwizzles #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3 static id (*__SWZ_initWithEventDispatcher_orig)(id self, SEL _cmd, id eventDispatcher); - (id)__swz_initWithEventDispatcher:(id)eventDispatcher { id returnValue = __SWZ_initWithEventDispatcher_orig(self, _cmd, eventDispatcher); if (@available(iOS 11.0, *)) { [(UIScrollView*)[returnValue valueForKey:@"scrollView"] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentAutomatic]; } return returnValue; } #endif + (void)applySwizzles { #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3 Class cls = NSClassFromString(@"RCTScrollView"); if(cls == NULL) { return; } Method m1 = class_getInstanceMethod(cls, NSSelectorFromString(@"initWithEventDispatcher:")); if(m1 == NULL) { return; } __SWZ_initWithEventDispatcher_orig = (void*)method_getImplementation(m1); Method m2 = class_getInstanceMethod([RNNSwizzles class], NSSelectorFromString(@"__swz_initWithEventDispatcher:")); method_exchangeImplementations(m1, m2); #endif } @end