gpt4 book ai didi

iOS:一次滚动一个单元格

转载 作者:可可西里 更新时间:2023-11-01 06:18:56 25 4
gpt4 key购买 nike

我现在设置了水平滚动,我希望它在左右滚动时一次滚动/捕捉一个单元格。

有人能解释一下吗?这是我到目前为止的代码:

- (void)viewDidLoad
{
[super viewDidLoad];
}

#pragma mark - UICollectionView Datasource

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return 1;
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 20;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MyCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"MyCell" forIndexPath:indexPath];
cell.backgroundColor = [UIColor whiteColor];
return cell;
}

#pragma mark - UICollectionViewDelegateFlowLayout

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
return UIEdgeInsetsMake(50, 20, 50, 20);
}

最佳答案

[collectionView setPagingEnabled:YES]; 可以解决这个问题吗?

http://adoptioncurve.net/archives/2013/04/creating-a-paged-photo-gallery-with-a-uicollectionview/

关于iOS:一次滚动一个单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21296339/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com