tableview或者collectionView列表滑动到顶部的三种方法

来源:互联网 发布:阿里云域名管理平台 编辑:程序博客网 时间:2024/05/19 00:13
tableview或者collectionView列表滑动到顶部的三种方法

第一种:

    collectionView.contentOffset=CGPointMake(0, 0);


第二种:

    [collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] atScrollPosition:UICollectionViewScrollPositionTop animated:YES];

    

第三种:

    [collectionView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];

0 0