1、经常有表滑动,根据当前滑动的contentoffset来决定界面的UI显示,不要傻乎乎的再去计算位移量等操作了,oc有提供方法:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
//获取collectionView中心的cell
NSIndexPath *centerindexPath = [self.collectionView indexPathForItemAtPoint:CGPointMake(scrollView.contentOffset.x + self.collectionView.width / 2.0, 0)];
//系统方法返回处于tableView某坐标处的cell的indexPath
NSIndexPath * indexPath = [collectionView indexPathForRowAtPoint:scrollView.contentOffset];
NSLog(@"滑到了第 %ld 组 %ld个",indexPath.section, indexPath.row);
}