Odd collection view scrolling behaviour with UITextField in UICollectionViewCell - ios

I have a UICollectionView with some UICollectionViewCells that contain UITextFields. When a UITextField is selected for editing, the keyboard shows and the UICollectionView moves up accordigly to make the active UITextField visible. I am relying on default behaviour with this and the UITextField is actually appropriately positioned when UIKeyboardDidShowNotification is launched. However, right after that, the UICollectionView will scroll automatically back to the top, and the UITextField will move out of view (behind keyboard).
What could be causing this and how could I debug this behaviour? Please note, that any custom code for UIKeyboardDidShowNotification like scrollRectToVisible or Apple's sample code will not help, as the scrolling off viewable areas happens at a later stage overriding that code. I am just unable to pinpoint the cause of this.
EDITED to add:
An animation to show how the view behaves with a hard keyboard (iPad Pro) when clicking Next to cycles fields. This works fine.
An animation to show how the view behaves with a soft keyboard when clicking Next to cycles fields. Here the keyboard avoiding does not work.

Related

Why UICollectionView offset changes when keyboard appears

I'm developing an iPad app, that has a horizontal UICollectionView. Each of the cells has a UITextField. When the UITextField becomes first responder, the keyboard automatically comes up, and surprisingly all the cells move upwards.
I haven't implemented any logic for the cells to move upwards. Do you know why?
I haven't found any documentation regarding this, and I'm unable to fix this.
This behaviour is implemented by Apple. The standard UICollectionView takes care for you to scroll to the correct position if a keyboard appears. Why would you want to fix this?

UIView with container view not scrolling properly when keyboard appears

I have an issue dealing with a UIContainerView inside a UIView. When I try to show the keyboard to edit one of the fields I would expect the whole UIView (with the UIContainerView inside it) to scroll up and out of the way of the keyboard.
Here is what I see at the moment. Does anybody have any suggestions on how to resolve this issue?
The automatic scrolling for input only happens in things like UITableView. For this one, refer to the Apple guide of managing keyboards.
Essentially, you want to manually scroll up the view when the keyboards appear and put it back when the keyboard is hidden.
Edit: I just realised that you have a
UITableViewController. My guess would be because it's on fullscreen, the table view doesn't have enough room to scroll. In this case, you would need to put the all the views inside a scroll view and follow the guide above.

UIScrollView receiving taps but not contentView

I have a ViewController setup like so:
-View
--scrollView
---contentView (UIView)
All of my content is in the contentView. Most of the content is UITextFields that I added programmatically to fashion a form-like setup. I can touch the text fields when I first enter the View Controller to bring up the keyboard to type on them, however, as soon as I scroll down (so I can see the rest of the textfields on the view) none of them respond to touch, even the ones that I could originally see and interact with when I first entered the view controller. There is, however, one button that I added from the storyboard that will continuously accept touch events even after scrolling, but the textfields I added programmatically will not.
I added log statements in gestureRecognizers to deduce that after I move the page down to see the rest of the textFields, only the scrollView picks up taps, and not the contentView underneath it that holds all of the textfields.
I don't have the first clue as to where to look for this sort of situation. Any help would be awesome, this is my first app so things are coming along slowly. Thanks so much in advance.

Strange UICollectionView behaviour when VoiceOver is enabled

I have a UICollectionView that each of it's cells is a UIWebView, where the last cell contains a link that pushes another UIViewController on screen. This UIViewController has a back button that pops the UIViewController off screen and should display the last cell on the UICollectionView again.
This flow works fine when VoiceOver is turned off, however when VoiceOver is turned on, when the user taps on the back button - the collection view automatically scrolls back to the first cell.
I've googled this to death, but nothing seems to work.
Any suggestions?

iOS: Disable UITableView animation when keyboard shows up

Everyone wants to move the UITableView when the keyboard pops up, but I'm looking for a way to disable the automatic animation to the cursor when the keyboard pops up. I'm experiencing an odd jerking / jolting / erratic scrolling behavior when the keyboard pops up and causes the UITableView to scroll to the cursor (to avoid blocking it).
Each of my UITableView cells has a UITextView in it. I don't commit any other animations when the keyboard pops up.
At this point, I would like to disable the animation completely and manually scroll to a desired CGPoint.
Thank you!
The automatic scrolling code resides in tableViewController, so auto-scrolling can't be disabled. Instead of subclassing from UITableViewController you can subclass from UIViewController and use a tableView inside it.
If you are willing to use UITableViewController itself, you can override viewWillAppear and don't call [super viewWillAppear].

Resources