移动开发

iOS11 UITextField 内存泄露retainCycl

2018-01-19  本文已影响14人  四月的风_3cec

项目中使用 'MLeaksFinder',提示UITextField leak,

临时打了个补丁解决iOS11 下UITextField 私有变量的retaincycle

- (void)willMoveToWindow:(UIWindow *)newWindow

{

    [super willMoveToWindow:newWindow];

    if (@available(iOS 11.0, *)) {//a temp solution to fix { UITextField private-var retaincycle.}

        if (!newWindow) {

            NSString *keyPath = @"textContentView.provider";

            [self.passwordTextField setValue:nil forKeyPath:keyPath];

        }

    }

}

上一篇 下一篇

猜你喜欢

热点阅读