damienpontifex / BlogCodeSamples

Code that was used in blog posts. Generally for my own experimentation and reminders, but hopefully useful to others
https://www.damienpontifex.com/
44 stars 16 forks source link

Text View scrolls to top if you try edit the bottom line. #3

Open swaterfall opened 9 years ago

swaterfall commented 9 years ago

After adding the fix for #1 I noticed that if you tap the last line of the text view to bring up the keyboard it scrolls to the top. It only seems to happen when you tap the last line.

If you add this line of code to viewDidLoad:

    tableView.keyboardDismissMode = UIScrollViewKeyboardDismissMode.OnDrag

Then add a bunch of text into the text box so its bigger than the screen, scroll up to dismiss the keyboard. Now if you tap the bottom row to start editing again it scrolls to the top.

Any ideas?

damienpontifex commented 9 years ago

Agreed, can reproduce. I have done some brief searching and haven't found any direct solutions.

May have to register for the UIKeyboardWillShowNotification notification and scroll/offset to have the selected area visible. Will do some more testing.

damienpontifex commented 8 years ago

@swaterfall long time, but I've updated the code to iOS 10 and using a UIStackView to layout the elements. Testing on my device this doesn't seem to be occurring now. Could you test with latest code and confirm?