您的当前位置:首页正文

iOS11 UITextField 内存泄露retainCycl

来源:花图问答

项目中使用 '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];

        }

    }

}