IQKeyboardManager icon indicating copy to clipboard operation
IQKeyboardManager copied to clipboard

textview reloadLayoutIfNeeded positioning is not accurate

Open cs571393 opened this issue 3 years ago • 7 comments

When the height of the textview in the uicollectionViewcell is too high, when reloadLayoutIfNeeded, it will return to the top of the cell. Causes the textview to be obscured by the keyboard.

Versions

Xcode: 13.4.1 Mac OS: 12.3.1 Simulator/Device: Simulator SE3 Simulator/Device Name: iPhone SE3 Library Version: 6.5.10

cs571393 avatar Jun 29 '22 06:06 cs571393

Can you please share a demo project with me?

hackiftekhar avatar Jul 30 '22 08:07 hackiftekhar

test.zip

https://user-images.githubusercontent.com/19399512/182302958-e6d90860-9ec2-41be-8430-2bbe5d029605.mov

@hackiftekhar

cs571393 avatar Aug 02 '22 06:08 cs571393

I technically got why the problem is happening. It's happening because the origin of the textView is itself out of the screen, so there are some miscalculations or may be something not good happening due to this. But for a solution/fix it would take some time since I need to dig into the complex code.

hackiftekhar avatar Aug 08 '22 15:08 hackiftekhar

Look forward to a fix for this issue

cs571393 avatar Aug 12 '22 03:08 cs571393

I tried to reproduce this with the latest version of the library and I no longer able to reproduce the issue, so it looks like it get's fixed somehow with some of the recent changes.

hackiftekhar avatar Oct 02 '23 13:10 hackiftekhar

test.zip

https://github.com/hackiftekhar/IQKeyboardManager/assets/19399512/d672ad07-95be-458b-a258-150342929d6e

IQKeyboardManagerSwift Version (6.5.6) I still have the same problem trying to run this demo

cs571393 avatar Oct 10 '23 01:10 cs571393

@hackiftekhar

cs571393 avatar Oct 10 '23 01:10 cs571393

I got the point @cs571393 however this is expected behavior in your case. Because when you scroll, you scroll the scrollview not the textView.

So when you call reloadLayoutIfNeeded(), it reposition the scrollView which is expected if you call this function.

From development perspective you shouldn't be putting a scrollView (UITextView in your case) inside another scrollView which may produce undefined behavior like yours.

From the technical perspective it's working as I would expect and unfortunately you should consider changing the UI elements a little bit to not include scrollview inside another scrollview to fix it.

hackiftekhar avatar Mar 10 '24 15:03 hackiftekhar