zoukankan      html  css  js  c++  java
  • iOS UIScrollView滚动方法对比

    项目中我们经常会使用到使视图滚动的方法,不管是collectionview或者是tableview最终都是使用以下方法

    -(void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;//以恒定速度动画到新偏移
    -(void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated;//滚动使rect刚好可见(最近的边)。如果完全可见就什么都没有

    但在某些系统下 -(void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated;方法滚动并不生效。

    可以使用 -(void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;方法替代。

    //    这个方法在部分系统下不好使 有莫名其妙的问题 时好时不好
    //    [self.contentCollectionView scrollRectToVisible:CGRectMake(indexPath.row*LL_ScreenWidth,self.contentCollectionView.frame.origin.y, self.contentCollectionView.frame.size.width, self.contentCollectionView.frame.size.height) animated:NO];
        
        [self.contentCollectionView setContentOffset:CGPointMake(toRow*LL_ScreenWidth, 0) animated:NO];
  • 相关阅读:
    Linux密码文件介绍
    MongoDB与微服务
    MongoDB应用场景及选型
    MongoDB性能诊断工具
    1.7每日进度
    《架构即未来》(3)
    《架构即未来》(2)
    论面向服务架构设计
    浅谈MVC设计模式
    《架构即未来》(1)
  • 原文地址:https://www.cnblogs.com/lijianyi/p/13964046.html
Copyright © 2011-2022 走看看