Post not yet marked as solved
Post marked as unsolved with 3 replies, 535 views
When I use UICollectionView on iPhone13 and the latest devices, [collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:section] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES] will cause caton. animated:YES has no animation effect, but this method works well on other devices, They are IOS 15.0.2 systems
- (void)topClick:(UIButton *)sender{
if (sender.selected) {
return;
}
NSArray *array = [NSArray array];
if (sender == self.topLuck) {
array = self.luckList;
} else if (sender == self.topLuxurious){
array = self.luxuriousList;
} else if (sender == self.topVip){
array = self.vipList;
} else if (sender == self.topPk){
array = self.pkList;
} else if (sender == self.packetBtn){
array = self.packetList;
}
NSInteger section = [self.datas indexOfObject:array];
// [self didScrollToSection:section];
if (section < self.datas.count) {
[self.giftCollectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:section] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];
}
}
- (UICollectionView *)giftCollectionView{
if (!_giftCollectionView) {
LiveGiftPickerLayout *layout = [LiveGiftPickerLayout new];
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
layout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
CGFloat width = floor((kScreen_Width - 20)/4);
layout.itemSize = CGSizeMake(width, width);
layout.minimumLineSpacing = 0;
layout.minimumInteritemSpacing = 0;
_giftCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_giftCollectionView.dataSource = self;
_giftCollectionView.delegate = self;
_giftCollectionView.backgroundColor = [UIColor clearColor];
_giftCollectionView.showsHorizontalScrollIndicator = NO;
_giftCollectionView.pagingEnabled = YES;
[_giftCollectionView registerClass:[GiftPickerCollectionViewCell class] forCellWithReuseIdentifier:[GiftPickerCollectionViewCell currentIdentifier]];
}
return _giftCollectionView;
}