UICollectionViewController + UITextField autoscroll behavior

Hi all! I have a UICollectionViewController with cells that contain UITextField items. On iOS 14, switching firstResponder status between each text field programmatically caused the UICollectionView to auto-scroll the items into view.

On iOS 15 this behavior still occurs, but the animation is jittery. The scrollview jumps up and down rapidly while the animation occurs.

As a sanity check, I have no other code executing while this animation occurs. The contentInsets and contentOffset are only being affected by the firstResponder animation.

Any ideas why this might be happening?

Is it on device or on simulator ?

Is it exactly the same code you run on iOS 14 and iOS 15 ? Did you recompile with another version of Xcode ?

Do you test on the same model of iPhone ? Otherwise, that could be a constraints issue.

Could you show the code where you change firstResponder ?

• This is on both an iPhone 12 and the simulator.

• This is the same code on both operating systems.

• I was previously using Xcode 12, but upgraded to the the Xcode 13 RC.

• I'm testing on the same model (both simulator and my personal dev device are iPhone 12s)

• The code where I change first responder is pasted below.

- (void)didPressNextButton {
    if (currentReponderIndex == self.textFields.count - 1) {
        NSNumber *tag = [self.textFields firstObject];
        UITextField *field = [self.view viewWithTag:tag.integerValue];
        [field becomeFirstResponder];

    } else {
        NSNumber *tag = [self.textFields objectAtIndex:currentReponderIndex + 1];
        UITextField *field = [self.view viewWithTag:tag.integerValue];
        [field becomeFirstResponder];
    }
}

How much jitter do you get ? a few pixels or much more ? Is it when the cell is not completely visible or is it in all cases ?

I found this: could it help ? 

h t t p s : / / stackoverflow.com/questions/17435805/uicollectionview-activating-scrolling-to-and-assigning-first-responder-to-dis

More questions than answers, sorry…

  • Did the problem occur with Xcode 12 ?
  • Could you show any code for Collection layout ?
  • Could be that iOS uses values to scroll before adapting to correct cell sizes ? That's just a guess.
  • Are all the cells of the same size ?
  • Have you a minimum example to try and reproduce ?

• I don't recall seeing this issue in the two months of previous testing on iOS 14 using Xcode 12.

• I'm using UICollectionViewCompositionalLayout with estimated heights that are about the same size as the rendered rows. I also have header and footer boundary elements.

• I thought it could be a layout pass as well, but when scrolling to the fields on my own, I don't see any jitter. It's only when the keyboard is visible and the system attempts to scroll the view.

• All the cells are the same size.

• I have prepared a minimum example and the issue is reproducible. dropbox.com/s/fpqy2tx7gpvdd69/CollectionViewTesting.zip?dl=0

I have submitted a bug report to Apple with this example project. ID is FB9640529.

UICollectionViewController + UITextField autoscroll behavior
 
 
Q