iOS 14.3 UITextField leak?

Why is the UIKeyboard implementation still holding a reference to this UITextField, thus keeping it from being deallocated?

The memory debugger shows:

UIKeyboardImpl -> UIKBAutofillController -> NSMutableDictionary -> NSMutable...(Storage) -> UITextField

Any idea what's going on there?

Accepted Reply

It seems to disappear if I set:

Code Block
textField.autocorrectionType = UITextAutocorrectionType.no


I tried that because of the UIKBautofillController pointing to the field in the memory debugger.
  • It helps if keyboardType = .default, but doesn't for numberPad, for example - UIKBautofillController retains text field again.

    In my case it was phone number field, so I set textContentType = nil and tried to prevent heuristics to detect content type - removed placeholder, renamed outlet and field class; still no luck - autofill controller was here.

Add a Comment

Replies

I cannot offer any help, but I have the same issue. I noticed that it appears when I switch the view while the cursor is still in the text field. I tried adding resignFirstResponder in different ways, it did not help.
It seems to disappear if I set:

Code Block
textField.autocorrectionType = UITextAutocorrectionType.no


I tried that because of the UIKBautofillController pointing to the field in the memory debugger.
  • It helps if keyboardType = .default, but doesn't for numberPad, for example - UIKBautofillController retains text field again.

    In my case it was phone number field, so I set textContentType = nil and tried to prevent heuristics to detect content type - removed placeholder, renamed outlet and field class; still no luck - autofill controller was here.

Add a Comment

If anyone (else) is coming across this issue with their custom UITextInput control. The following work around will work (assuming you don't need autocorrect):

var autocorrectionType: UITextAutocorrectionType {
    get { .no }
    set { fatalError() }
}