2

I've been battling an issue in Xcode for a couple of days now and I can't figure out what's wrong. I've created a simple UIViewcontroller with three separate Textfields. When I run the app in the simulator or on a physical device, I get this warning in the console when I tap on the textfields. It happens only when I tap on the next textfield without dismissing the keyboard first. If I dismiss the keyboard after every textfield input, there are no debug console complaints. But when I don't the console returns the following on tapping the next textfield.

"[LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it.

"<NSLayoutConstraint:0x281f15bd0 'assistantHeight' TUISystemInputAssistantView:0x14602a340.height == 55   (active)>",
"<NSLayoutConstraint:0x281f2de00 'assistantView.bottom' TUISystemInputAssistantView:0x14602a340.bottom == _UIKBCompatInputView:0x1460631d0.top   (active)>",
"<NSLayoutConstraint:0x281f2fcf0 'assistantView.top' V:|-(0)-[TUISystemInputAssistantView:0x14602a340]   (active, names: '|':UIInputSetHostView:0x143e5cd50 )>",
"<NSLayoutConstraint:0x281f17200 'inputView.top' V:|-(0)-[_UIKBCompatInputView:0x1460631d0]   (active, names: '|':UIInputSetHostView:0x143e5cd50 )>"

Will attempt to recover by breaking constraint Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful."

I have created a new, clean UIViewcontroller with nothing inside, just three simple textfields and I still experience this issue. I've done this, because in my original project, I had the textfields arranged inside a stackview and thought that might be causing the issue, but it clearly isn't.

Has anyone encountered this issue?

Thanks very much for your time and any help!

3 Answers 3

2

I believe that this is a bug in apple's implementation of the keyboard.

So the work around for this is set autocorrection type of text field to no

textField.autocorrectionType = .no

Sign up to request clarification or add additional context in comments.

Comments

1

The layout constraint error message has nothing to do with your layout.

It's an internal issue (could be considered a bug) with the Input Assistant View - the auto-complete options shown above the keyboard.

If you use Debug View Hierarchy you can find the culprit listed in the error message: TUISystemInputAssistantView

You can ignore this error / warning message, as it is out of your hands.

Edit

The error / warning message shows:

"<NSLayoutConstraint:0x281f15bd0 'assistantHeight' TUISystemInputAssistantView:0x14602a340.height == 55   (active)>",

Here is what you can find using Debug View Hierarchy:

enter image description here

As you can see, the "offending element" is the TUISystemInputAssistantView which is part of iOS internal functionality.

9 Comments

So there is nothing I can do to prevent this from happening? It doesn't break the app, but is still a weird annoyance. I imagine there must be a lot of people, who have run into this issue...
You can prevent it by disabling Correction, but that means Correction is disabled. If your implementation doesn't need that, great. Otherwise, no, nothing you can do. And yes, if you search, you'll find other questions about this.
Thanks DonMag, I've set the Correction option of Text Input Traits in Interface Builder to No and still get the same message. I guess I'll have to make do with ignoring the message. Wish I haven't wasted so much time chasing the solution, sigh... Thanks again!
Just a followup on the topic, when I use the Debug View Hierarchy, more "complaints" appear in the console. The console states "[External] -[UIInputViewController needsInputModeSwitchKey] was called before a connection was established to the host application. This will produce an inaccurate result. Please make sure to call this after your primary view controller has been initialized." It prints this error four times without me touching anything. I'm really confused.
Also internal.... in complex apps - particularly when using multi-threading, for example - you can get lots of error / warning messages in the console when dropping into Debug View Hierarchy.
|
0

You might be facing issue, while setting constraints, so I've done it, similar to you, and able to tap on the next textfield without dismissing the keyboard first.

I've tested below solution. You can try this solution.

I hope it will solve your issue.

class ViewController: UIViewController {

    let nameTextField: UITextField = {
        let textField = UITextField()
        textField.placeholder = "Enter your name here"
        textField.layer.borderWidth = 1
        textField.borderStyle = .roundedRect
        textField.translatesAutoresizingMaskIntoConstraints = false
        return textField
    }()

    let ageTextField: UITextField = {
        let textField = UITextField()
        textField.placeholder = "Enter your age here"
        textField.keyboardType = .decimalPad
        textField.layer.borderWidth = 1
        textField.borderStyle = .roundedRect
        textField.translatesAutoresizingMaskIntoConstraints = false
        return textField
    }()

    let cityTextField: UITextField = {
        let textField = UITextField()
        textField.placeholder = "Enter your city name here"
        textField.layer.borderWidth = 1
        textField.borderStyle = .roundedRect
        textField.translatesAutoresizingMaskIntoConstraints = false
        return textField
    }()

    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.addSubview(nameTextField)
        self.view.addSubview(ageTextField)
        self.view.addSubview(cityTextField)

        NSLayoutConstraint.activate([

            //nameTextField
            self.nameTextField.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: 100),
            self.nameTextField.leadingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.leadingAnchor, constant: 16),
            self.nameTextField.trailingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.trailingAnchor, constant: -16),


            //ageTextField
            self.ageTextField.topAnchor.constraint(equalTo: self.nameTextField.bottomAnchor, constant: 16),
            self.ageTextField.leadingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.leadingAnchor, constant: 16),
            self.ageTextField.trailingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.trailingAnchor, constant: -16),

            //cityTextField
            self.cityTextField.topAnchor.constraint(equalTo: self.ageTextField.bottomAnchor, constant: 16),
            self.cityTextField.leadingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.leadingAnchor, constant: 16),
            self.cityTextField.trailingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.trailingAnchor, constant: -16),

            ])
    }
}

8 Comments

The same error message occurs with your example if you already have text in the fields.
It should not give any error...It's running perfectly, though I've text in textfield
Type some text in the first field... and in the second field... and in the third field... then tap back in the first field where you already have text. You'll get the error.
No...I'm not getting any error at my end....it runs perfectly
Or, just type in the first field and then tap in the third field... skip the numeric-entry field.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.