Why UICollectionView offset changes when keyboard appears - ios

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?

Related

Is there a way to change scrollview focus programatically?

In Swift, is there a way to change scrollview focus programatically? For example, in one of my scrollviews when a user is scrolling, after the scroll has gone past a certain distance I want the scroll to stop scrolling and to immediately scroll a tableview instead. I want this to all happen in the same motion/swipe, so I need to automatically shift the focus from the scrollview to the tableview using code. Is this possible?
Using Rikh's comment, I was able to solve this using a UITableView with multiple sections and custom UITableView headers. I can use the viewForHeaderInSection method to create a custom floating header which is exactly what I need and it scrolls much more smoothly.

Odd collection view scrolling behaviour with UITextField in UICollectionViewCell

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.

UIScrollView behaves differently after UITableView has been selected

I've been trying to fix this issue all day but can't seem to figure out what's going wrong. I have a UIScrollView which has a UITableView and numerous UITextFields as subviews. When I click the UITextField the UIScrollView will adjust it's contentOffset so the textfield appears above the keyboard. This all works fine until I click on the UITableView and select a cell, after this the UIScrollView performs an extra check and scrolls down about 50 pixels after the first contentOffset change. This is hard to explain so I have attached a video here which demonstrates what happens:
http://tinypic.com/r/14xj6gn/8
Has anyone experienced this or know how to fix it?
Thanks for any help.
Okay, so I found out the reason it happens. If anyone needs help then read this post here:
Disable UIScrollView scrolling when UITextField becomes first responder

UIImageview animation and UILabel inside UICollectionview disappearing

I'm having problems with an animation inside the UICollectionview cell. When I touch my animation, it disappear. I have a refresh time of 8 seconds and when this time is reached, the animation back to normal. My labels inside the cells are having the same issue. It's weird this behavior because when I use static images, they don't disappear.
Arrived while looking for the answer to this. Faced similar issue. Image animation would stop when clicked on the collectionViewCell.
Not sure what the bug is, but one solution that worked for me, was to disable selection on the CollectionView.
In case, you do not need selection on the collection view, just set allowsSelection to NO for the collection view and the bug will go away.

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