【问题标题】:Auto Scroll Collelction view in Objective cObjective c中的自动滚动收集视图
【发布时间】:2018-07-06 12:24:13
【问题描述】:

我有一个集合视图,其中每个单元格都有图像。我需要在集合视图上执行自动滚动,但不知道如何操作?

附: - 需要知道目标中的实现 - c

【问题讨论】:

    标签: ios objective-c iphone uicollectionview autoscroll


    【解决方案1】:

    你可以使用scrollview方法来做到这一点

    快速

    collectionView.scrollToItem(at: IndexPath.init(item: item, section: section), at: UICollectionViewScrollPosition, animated: true)
    

    针对目标 c

    [self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:indexpathofitem inSection:section] 
                        atScrollPosition:UICollectionViewScrollPosition
                                animated:YES];
    

    【讨论】:

    • 它经常滚动。有什么办法可以实现慢一点。就像用计时器滚动
    【解决方案2】:

    你可以试试这个

    [self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] 
                            atScrollPosition:UICollectionViewScrollPositionBottom
                                    animated:YES];
    

    //

    在每 1 秒滴答一次的计时器内

    [self.collectionView setContentOffset:CGPointMake(0,yValue)];
    

    【讨论】:

    • 谢谢。但它经常滚动。有什么办法可以实现慢一点。就像用计时器滚动
    • 可以设置contentOffset
    猜你喜欢
    • 2016-02-23
    • 1970-01-01
    • 1970-01-01
    • 2012-10-26
    • 1970-01-01
    • 1970-01-01
    • 2017-01-07
    • 1970-01-01
    相关资源
    最近更新 更多