Disable the keyboard suggestions for a UITextField

I have a UITableView with a bunch of UITextFields in 'em. (in a custom UITableViewCell subclass) For every UITextField I have set:

    cell.textField.textContentType = .none

I even tried:

    cell.textField.inlinePredictionType = .no // iOS >= 17 

and:

    cell.textField.keyboardType = .default
    cell.textField.autocorrectionType = .no
    cell.textField.spellCheckingType = .no
    cell.textField.autocapitalizationType = .none

Still, when I tap in one of them, I get a 'suggestion' in a bar just above the Keyboard that I can fill in my phone number.

How can I prevent that?

I am using: xcode 15.4, iOS 17.5.1. Compiling for iOS 13.0 and later.

Answered by DTS Engineer in 789402022

@Woutster You should only have to set autocorrectionType to no and specify the keyboardType


 textField.autocorrectionType = .no
 textField.keyboardType = .phonePad

Even this did not solve the problem:

            if let item = textFieldCell.textField?.inputAssistantItem {
                item.leadingBarButtonGroups = []
                item.trailingBarButtonGroups = []
            }

@Woutster You should only have to set autocorrectionType to no and specify the keyboardType


 textField.autocorrectionType = .no
 textField.keyboardType = .phonePad
Accepted Answer

Hi @Woutster,

I ran into the same issue and I just can't disable the phone and email suggestions. I tried a lot of combinations until I found the culprit... It was the placeholder texts!

In my app, I have an email UITextField and, under it, a phone number UITextField. The placeholder, for the former, is "Email" and, for the latter, is "Phone Number". It is only when these two fields (with these placeholders) are next to each other that this issue occurs.

Then, I tried your placeholders "Je email adres" and "Je KvK nummer"... I got the same result.

Anyway, I don't know what's causing this behavior, if it's a bug or not. My suggestion as your workaround is to move the "Je KvK nummer" text field away from the email.

I hope this helps.

Disable the keyboard suggestions for a UITextField
 
 
Q