iOS11 UITextField 内存泄露retainCycle

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

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

- (void)willMoveToSuperview:(UIWindow *)superview

{

    [super willMoveToSuperview:superview];

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

        if (!superview) {

            NSString *keyPath = @"textContentView.provider";

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

        }

    }

}

你可能感兴趣的:(iOS11 UITextField 内存泄露retainCycle)