My App has wrong behavior when I used UICollectionView API - scrollToItemAtIndexPath.( ios15 beta4)

Model : iPhone 12 pro max

System : iOS 15 beta4

Desc : I set the collectionView to scroll to the back of the item, but it actually scrolls to the front. The problem is currently only in iPhone 12pro max.

NSInteger row = indexPath.item + 1; 
if (row > 0 && row < [self.dataSource collectionView:self numberOfItemsInSection:indexPath.section]) {   
     [UIView animateWithDuration:.3 animations:^{       
         [self scrollToItemAtIndexPath:[NSIndexPath    indexPathForRow:row inSection:indexPath.section]   atScrollPosition:UICollectionViewScrollPositionNone  animated:NO];      
      }];
 }
Answered by QiuZH in 687157022

It is correct in iOS 15 beta8

NSInteger row = indexPath.item + 1;   if (row > 0 && row < [self.dataSource collectionView:self numberOfItemsInSection:indexPath.section]) {         [UIView animateWithDuration:.3 animations:^{               [self scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:row inSection:indexPath.section] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];               }];   }

to the back of the item, but it actually scrolls to the front

Do you mean you want to scroll to next item and it scrolls to previous ?

Does the problem still occur if you remove animation ?

Could you try and change UICollectionViewScrollPositionNone to UICollectionViewScrollPositionCenteredVertically and tell what you get ?

Could you also log the value of indexPath and check it is correct one.

Accepted Answer

It is correct in iOS 15 beta8

My App has wrong behavior when I used UICollectionView API - scrollToItemAtIndexPath.( ios15 beta4)
 
 
Q