iOS 11 textField記憶體洩漏問題

獨樂樂發表於2018-01-11

1.自定義textField在iOS 11 系統下記憶體洩漏臨時解決辦法。

- (void)removeFromSuperview{
    NSString *version = [UIDevice currentDevice].systemVersion;
    if (version.doubleValue >= 11.0) {
        id view = [self valueForKey:@"textContentView"];
        if (view) {
            [view removeFromSuperview];
            [self setValue:nil forKey:@"textContentView"];
        }
    }
}

2.UITextField在iOS 11 系統下記憶體洩漏臨時解決辦法。

新建UITextField Category.在Category中新增如下程式碼。

- (void)removeFromSuperview{
    NSString *version = [UIDevice currentDevice].systemVersion;
    if (version.doubleValue >= 11.0) {
        id view = [self valueForKey:@"textContentView"];
        if (view) {
            [view removeFromSuperview];
            [self setValue:nil forKey:@"textContentView"];
        }
    }
}

相關文章