Description
Describe the bug
When I pressed return on the keyboard to next to the next input, IQKeyboardManagerSwift miscalculated and pushed my header view to the top and was covered by the navigation bar.
To Reproduce
Steps to reproduce the behavior:
- Focus input 0
- Scroll down
- Enter key return in keyboard
- See error view fixed pushed
Expected behavior
I want the scroll area to automatically scroll to the area where the input is focused.
Screenshots/Videos
[Screenshoot]
[Video]
https://github.com/user-attachments/assets/d54c92bd-7e21-4c1e-8f6a-97b2bf3e417b
Demo Project
As in the video reproducing my error, there is only 1 fixed view, 1 scrollview containing inputs, pressing the return key on this input will focus on the next input.
Versions
Xcode: 16.2
Mac OS: 14.7.5
Simulator/Device: Simulator
Simulator/Device Name: iPhone 15
Library Version: 6.5.0 (Lasted in 22/06/2025)
Additional context
My screen must have a view outside the scroll for it to be fixed.
I am assuming the height of the scrollview = 1000px, the height of the fixed view = 100px
[LOG IQKeyboardManagerSwift]
IQKeyboardManager| >>>>> adjustPosition() started >>>>>
IQKeyboardManager| | Need to move: -899.0, will be moving down
IQKeyboardManager| | old contentOffset: (0.0, 680.6666666666666)
new contentOffset: (0.0, 10.0)
IQKeyboardManager| | Remaining Move: 100.0
IQKeyboardManager| | Moving Upward
IQKeyboardManager| | Set ViewController origin to: (0.0, -100.0)
IQKeyboardManager| <<<<< adjustPosition() ended <<<<<
According to the log, your IQKM calculates when pressing enter on the keyboard when the scroll is at the end => it needs to move up 899 units, but the offset it is currently at is 680.666 and cannot scroll up 899 units => it pushed my rootview up a segment equal to the distance from the scrollView to the navigation bar
It is absurd that I can scroll down but it says it cannot scroll up and must push the rootview.
In my opinion, it only needs to scroll up a segment equal to 680.666 to be able to display the input that is focused, maybe your calculation of the scroll distance is wrong somewhere, I am not sure about this.
Thank you for reading.