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];      
      }];
 }
  • 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];               }];   }

Add a Comment

Accepted Reply

It is correct in iOS 15 beta8

Replies

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.

  • Do you mean you want to scroll to next item and it scrolls to previous ? right. I don't need to scroll to the center. The requirement is to click on the half-hidden cell and scroll to a position where it can be fully displayed

  • My English is not very good, please don't mind.

  • The value of indexPath is no problem, I compared iphone12. The same value and operation

It is correct in iOS 15 beta8