hackiftekhar / IQKeyboardManager

Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more.
MIT License
16.39k stars 2.4k forks source link

Layout constraint problem, Xcode 11 and iOS 13 #1616

Closed JeffersonSchuler closed 4 years ago

JeffersonSchuler commented 4 years ago

Describe the bug Getting a layout constraint error now that I have upgraded to Xcode 11 and iOS 13 on a real device. Selecting a UITextfield that has "secure text entry" enabled causes the following error:

[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:0x281b94b90 'accessoryView.bottom' _UIRemoteKeyboardPlaceholderView:0x104ffa200.bottom == _UIKBCompatInputView:0x108707890.top (active)>", "<NSLayoutConstraint:0x281b7f840 'assistantHeight' TUISystemInputAssistantView:0x108531590.height == 45 (active)>", "<NSLayoutConstraint:0x281b919a0 'assistantView.bottom' TUISystemInputAssistantView:0x108531590.bottom == _UIKBCompatInputView:0x108707890.top (active)>", "<NSLayoutConstraint:0x281b91680 'assistantView.top' V:[_UIRemoteKeyboardPlaceholderView:0x104ffa200]-(0)-[TUISystemInputAssistantView:0x108531590] (active)>" )

Will attempt to recover by breaking constraint <NSLayoutConstraint:0x281b91680 'assistantView.top' V:[_UIRemoteKeyboardPlaceholderView:0x104ffa200]-(0)-[TUISystemInputAssistantView:0x108531590] (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

Expected behavior No constraint issues.

Versions

Xcode: Version 11.0 (11A420a) Mac OS: 10.15 Beta (19A573a) Simulator/Device: iOS 13.1 Simulator/Device Name: iPhone X Library Version: 6.5.0

RiberWang commented 4 years ago

same!

gask commented 4 years ago

For anyone that is still experiencing the freeze (but not the warnings anymore), use this: Disable 'Automatically Sync Pasteboard'. Simulator -> Edit -> Automatically Sync Pasteboard

MoElnaggar14 commented 4 years ago

I have the same problem in real devices

GyanHajela commented 4 years ago

I have the same problem in all simulator.

singleD commented 4 years ago

I think it's a problem caused by system keyboard, because I have the same problem without this pod

MoElnaggar14 commented 4 years ago

I thought this problem because of toolbar because when I disabled it , this problems was gone :)

hackiftekhar commented 4 years ago

I can confirm that the problem is related to the toolbar.

hackiftekhar commented 4 years ago

I had more information on this. I created a clean project with two textField one is having its inputView as a UIDatePicker and another one is a simple textField with autocorrection = default. This project does not contain our library.

I found out that this constraint violation issue occurs when we switch between those 2 textFields. I believe that this is not a bug in our library but apple's implementation of the keyboard. I'm also attaching the demo project I created. TextField Constraint violation Demo.zip

MeiYuLong commented 4 years ago

how to fix ,samebody done ?

hackiftekhar commented 4 years ago

It's a bug in Apple implementation @MeiYuLong.

john-gaz commented 4 years ago

Anyone found a work around?

anelad commented 4 years ago

Not yet I suppose.

emreond commented 4 years ago

I'm also having the same issue :(

YourDaddy2000 commented 4 years ago

FIX: disable the Correction for that TextField

lolgear commented 4 years ago

@hackiftekhar do you know id this bug in Apple bug report?

rgmyyw commented 4 years ago

I have the same problem in all simulator. +1

gokulprathin8 commented 4 years ago

Same issue. any workarounds? +1

lolgear commented 4 years ago

@gokulprathin8 It isn't a problem of IQKeyboardManager, it is Apple internal bug.

horseshoe7 commented 4 years ago

I'm not using this framework, but I am experiencing this bug. Does anyone have a solution? For me it's happening because I have an .inputView and an .inputAccessoryView on a UITextField.

hackiftekhar commented 4 years ago

@hackiftekhar do you know id this bug in Apple bug report?

Nope.

hackiftekhar commented 4 years ago

I'm not using this framework, but I am experiencing this bug. Does anyone have a solution? For me it's happening because I have an .inputView and an .inputAccessoryView on a UITextField.

Please read previous comments for workarounds.

SDPrio commented 4 years ago

I am not using IQKeyboardManager but I came across the exact same problem while work with two UITextFields where one uses the system keyboard and one has its own, custom inputView (a UIDatePicker). When switching from the DatePicker TextField to the normal one the constraint error is shown. In rare cases it happens that the DatePicker inputView is not shown anymore when switching back.

I digged a little deeper and found out, that the custom inputView is places within a UIInputSetHostView which also contains (beside others) a TUISystemInputAssistantView. When the custom inputView is shown everything is fine and there are no conflict. However, when switching to the TextField with the standard keyboard, the height of the TUISystemInputAssistantView is set to 45 which conflicts with the top constraint which is set to the custom inputView...

Long story short: A hacky workaround for this problem is to manipulate the the constraints which are set inputView and give them a slightly lower priority :

func updateConstraintsWhenCustomKeyboardIsShown(customInputView: UIView) {
        if let superview = customInputView.superview {
            for constraint in superview.constraints {

                if (constraint.secondItem === customInputView && constraint.secondAttribute == .top) {
                    constraint.priority = UILayoutPriority(999)
                }
            }
        }
}
kiviabrito commented 4 years ago

FIX: disable the Correction for that TextField

This fixed my problem, tks!! Swift 5 txtField.autocorrectionType = .no

netgfx commented 4 years ago

Any solutions for this? I already have autocorrectionType = false but when autofill password is enabled. But the view still jitters when I switch between 2 input fields.

kiviabrito commented 4 years ago

Any solutions for this? I already have autocorrectionType = false but when autofill password is enabled. But the view still jitters when I switch between 2 input fields.

Did you try setting to .no instead of false?

netgfx commented 4 years ago

Yes I meant .no still nothing... I believe if the Auto-Fill password keeps appearing then the problem will still be present.

Demircivi commented 4 years ago

Disabling autocorrection didn't work quite well for me, my issue is autofill actually. I'm experiencing this constraint issue in my OTP screen, when my device receives the OTP SMS autofill is being shown and it causes this bug to occur.

fabricetiennette commented 4 years ago

In MY case i fix this error by setting textfield correction to default

Screenshot 2020-05-05 at 11 53 06
netgfx commented 4 years ago

This does remove the auto correction, but it doesn't remove the password/email suggestion that also takes up space above the keyboard and causes the layout issue and up/down jumping of the form.

jimbrayrcp commented 4 years ago

The problem with my code was this...

I found that I had set the toolbar this way: let toolBar = UIToolbar(frame: CGRect(x: 0, y: 0, width: textView.frame.size.width, height: 44.0)) and the error was popping every time.

Now I have it set like this let toolBar = UIToolbar(frame: CGRect(origin: .zero, size: CGSize(width: 100, height: 44.0))) and the error is resolved.

Hope this helps.

ArikElb commented 4 years ago

I am also not currently using IQKeyboardMananger but encountered this issue and based on the info here and playing around with options in Xcode, I found that assigning a Content Type in Text Input Traits (other than the default 'Unspecified') resolved the issue for me. eg image

bugrym commented 4 years ago

FIX: disable the Correction for that TextField

Jun 2020, ur solution still works! Thanks a lot πŸ™πŸ»

netgfx commented 4 years ago

All these solutions work for auto suggestions etc, however the issue is still present on password/email suggestions that cannot be disabled unfortunately, so the "jumping" of the form still exists.

aksthelion commented 4 years ago

Following solution doesn't work for me.

The problem with my code was this...

I found that I had set the toolbar this way: let toolBar = UIToolbar(frame: CGRect(x: 0, y: 0, width: textView.frame.size.width, height: 44.0)) and the error was popping every time.

Now I have it set like this let toolBar = UIToolbar(frame: CGRect(origin: .zero, size: CGSize(width: 100, height: 44.0))) and the error is resolved.

Hope this helps.

xingheng commented 3 years ago

I used UITextView and found this, the auto-correction and spell checking don't work for me, either.

textView = UITextView()
textView.autocapitalizationType = .none
textView.autocorrectionType = .no
textView.spellCheckingType = .no
textView.smartQuotesType = .no
textView.smartDashesType = .no
textView.smartInsertDeleteType = .no
lexuanquynh commented 3 years ago

it't not working with. me

wzj583585700 commented 3 years ago

θ‹ΉζžœθΏ™δΉˆεžƒεœΎε—

pigflymoon commented 2 years ago

Same issue.
context: Xcode :Version 13.2.1 Simulator: iPad Pro (12.9-inch)

I have used 3 UITextField in my app for sign up page, email, password and username. I had same issue as described in the issue above at the beginning, have tried autocorrectionType = .no in the field, not working. Then I moved the password field to the bottom of other two fields , then it is working, But for Simulator iPhone13 still same warning. not sure why

bobbelkl commented 1 year ago

Disable the suggestions above the keyboard: spellCheckingType = .no

And if you are using a UIDatePicker for the accessoryView just use a non-default keyboard type . e.g. keyboardType = .phonePad

AlxndrIvnch commented 1 year ago

In case I want to show suggestions for some field, like - textField.textContentType = .telephoneNumber, then I have to disable IQKeyboardManager toolbar for that VC or ignore constraints warning, no other solution?

zafarivaev commented 8 months ago

Setting textField.textContentType = .oneTimeCode removed the Auto Layout warnings for me