Nawin Poolsawad
Nawin Poolsawad

Reputation: 259

IQKeyboardManager have an issue about scrolling offset when have multiple UITextfields in UIScrollView with Swift

Describe the bug

When I have multiple textfields on same scrollview, ScrollView will have mistake scrolling offset after I transpose to each textfield. (You can see on demo video)

To Reproduce

Steps to reproduce the behavior:

  1. Start to select some textfield on the end of ScrollView
  2. transpose to select first textfield which can't see textfield on the end of scrollview
  3. The offset of scrollview will be incorrect here. (It looks like it scrolls to previous selected textfield)

Expected behavior

Scrolling offset must scroll to correct position

Demo video

https://user-images.githubusercontent.com/42397067/130907471-c4497741-c4fd-402b-8978-d76ee29b6b1a.MP4

According Demo video you will see. First, I entered on input11 field and after that I select on input2 but scrollview is scrolling to input11 again. I have no Idea what I'm doing wrong because this is normal textfield in scrollview that doesn't have any code.

Versions

Xcode: 12.5

Mac OS: Big sur 11.4

Simulator/Device: IphoneXr 14.4.2

Simulator/Device Name: IphoneXr

Library Version: ~> 6.5.0

UPDATED

It look like it's happened on only iOS 14+, Can't fix by myself. So many official app have problem like me. wait for apple...

Upvotes: 2

Views: 1855

Answers (1)

jiexishede
jiexishede

Reputation: 2613

I create a demo. The demo does not install the IQKeyboardManager, have my TableviewController which has an offset bug. UITableViewController works well in my demo. It is the Apple iOS System that controls the offset of UITableview when the keyboard will show.

In my opinion, maybe disabling the IQKeyboardManager will solve the problem.

I change enable like the code below. And I test in my project. The keyboard in my UITableViewContrller shows OK now.

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    IQKeyboardManager.shared().isEnabled = false

}

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)

    IQKeyboardManager.shared().isEnabled = true

}

Upvotes: 1

Related Questions