• UIScrollView的属性总结


     UIScrollView的属性总结
      
     
    属性 TableView 作用

    separatorStyle

    分割线

    rowHeight

    行高
       
       
       
     
     
    属性 作用
    CGPoint contentOffSet 监控目前滚动的位置
    CGSize contentSize 滚动范围的大小
    UIEdgeInsets contentInset 视图在scrollView中的位置

    id<UIScrollerViewDelegate> delegate

    //--视图拖拽时结束 键盘编辑窗口(如果窗口存在的话)

    - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView

    设置协议
    BOOL directionalLockEnabled 指定控件是否只能在一个方向上滚动
    BOOL bounces 控制控件遇到边框是否反弹
    BOOL alwaysBounceVertical 控制垂直方向遇到边框是否反弹
    BOOL alwaysBounceHorizontal 控制水平方向遇到边框是否反弹
    BOOL pagingEnabled 控制控件是否整页翻动
    BOOL scrollEnabled 控制控件是否能滚动
    BOOL showsHorizontalScrollIndicator 控制是否显示水平方向的滚动条
    BOOL showsVerticalScrollIndicator 控制是否显示垂直方向的滚动条
    UIEdgeInsets scrollIndicatorInsets 指定滚动条在scrollerView中的位置
    UIScrollViewIndicatorStyle indicatorStyle 设定滚动条的样式
    float decelerationRate 改变scrollerView的减速点位置
    BOOL tracking 监控当前目标是否正在被跟踪
    BOOL dragging 监控当前目标是否正在被拖拽
    BOOL decelerating 监控当前目标是否正在减速
    BOOL delaysContentTouches 控制视图是否延时调用开始滚动的方法
    BOOL canCancelContentTouches 控制控件是否接触取消touch的事件
    float minimumZoomScale 缩小的最小比例
    float maximumZoomScale 放大的最大比例
    float zoomScale 设置变化比例
    BOOL bouncesZoom 控制缩放的时候是否会反弹(弹簧效果)
    BOOL zooming 判断控件的大小是否正在改变
    BOOL zoomBouncing 判断是否正在进行缩放反弹
    BOOL scrollsToTop 控制控件滚动到顶部

     

     

     
    //---UIScrollViewDelegate

    1
    @protocol UIScrollViewDelegate<NSObject> 2 3 @optional 4 5 - (void)scrollViewDidScroll:(UIScrollView *)scrollView; // 滚动any offset changes
     6 - (void)scrollViewDidZoom:(UIScrollView *)scrollView NS_AVAILABLE_IOS(3_2); // 被缩放 any zoom scale changes 
     7 
     8 //开始拖拽 called on start of dragging (may require some time and or distance to move)
     9 - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;
    10 // 如果用户拖动的话被称为“手指”。速度是分/毫秒。targetcontentoffset可能改变调整滚动视图来休息的地方called on finger up if the user dragged. velocity is in points/millisecond. targetContentOffset may be changed to adjust where the scroll view comes to rest   
    11 - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset NS_AVAILABLE_IOS(5_0);
    12 //结束拖拽如果它将继续减速运动之后called on finger up if the user dragged. decelerate is true if it will continue moving afterwards
    13 - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;
    14 
    15 - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView;   // 注意:无伦用户如何滑动scrollView,只要有滑动,就会调scrollViewWillBeginDecelerating,只有scrollView当加速度停止之后,才会调用scrollViewDidEndDecelerating   called on finger up as we are moving
    16 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;      // called when scroll view grinds to a halt
    17 
    18 - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView; // 如果调用called when setContentOffset/scrollRectVisible:animated: finishes. not called if not animating
    19 
    20 - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;     // return a view that will be scaled. if delegate returns nil, nothing happens
    21 - (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view NS_AVAILABLE_IOS(3_2); // called before the scroll view begins zooming its content
    22 - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale; // scale between minimum and maximum. called after any 'bounce' animations
    23 
    24 - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView;   // return a yes if you want to scroll to the top. if not defined, assumes YES
    25 - (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView;      // called when scrolling animation finished. may be called immediately if already at top
    26 
    27 @end
    @protocol UIScrollViewDelegate<NSObject>
    
    @optional
    
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView;  // 滚动 any offset changes
    - (void)scrollViewDidZoom:(UIScrollView *)scrollView NS_AVAILABLE_IOS(3_2); // 被缩放  any zoom scale changes
    
    // 开始拖拽  called on start of dragging (may require some time and or distance to move)
    - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;
    // called on finger up if the user dragged. velocity is in points/millisecond. targetContentOffset may be changed to adjust where the scroll view comes to rest
    - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset NS_AVAILABLE_IOS(5_0);
    // 手指停止拖拽时调用 called on finger up if the user dragged. decelerate is true if it will continue moving afterwards
    - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;
    
    - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView;   // 手指松开后的移动会被调用 called on finger up as we are moving
    - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;      // called when scroll view grinds to a halt
    
    - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView; // 当 动画(contentOffset和 scrollRect 发生变化时)结束时 ,如果没有动画,将不会调用. called when setContentOffset/scrollRectVisible:animated: finishes. not called if not animating
    
    - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;     // 返回一个将要被缩放的视图,如果代理返回 nil ,将不做任何事.return a view that will be scaled. if delegate returns nil, nothing happens
    - (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view NS_AVAILABLE_IOS(3_2); // 当放大自己的内容时 被调用 called before the scroll view begins zooming its content
    - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale; // 缩放,任何的弹簧动画之后被调用. scale between minimum and maximum. called after any 'bounce' animations
    
    - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView;   // 如果你想滚动到 the top ,return yes.如果没有定义,则默认 yes. return a yes if you want to scroll to the top. if not defined, assumes YES
    - (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView;      //  当滚动动画结束.可能会立刻调用 如果已经 at top .called when scrolling animation finished. may be called immediately if already at top
    
    @end




     

    这里把UIScrollView的几个要点总结下:

    从你的手指touch屏幕开始,scrollView开始一个timer,如果:

    1.  150ms内如果你的手指没有任何动作,消息就会传给subView。

    2.  150ms内手指有明显的滑动(一个swipe动作),scrollView就会滚动,消息不会传给subView,这里就是产生问题二的原因。

    3. 150ms内手指没有滑动,scrollView将消息传给subView,但是之后手指开始滑动,scrollView传送touchesCancelled消息给subView,然后开始滚动。

    观察下tableView的情况,你先按住一个cell,cell开始高亮,手不要放开,开始滑动,tableView开始滚动,高亮取消。

    delaysContentTouches的作用:

    这个标志默认是YES,使用上面的150ms的timer,如果设置为NO,touch事件立即传递给subView,不会有150ms的等待。

    cancelsTouches的作用:

    这个标准默认为YES,如果设置为NO,这消息一旦传递给subView,这scroll事件不会再发生。

  • 相关阅读:
    Spring中的@Valid 和 @Validated注解你用对了吗
    linux 安装php_fileinfo扩展
    长链接,案例
    小程序,if 语句嵌入控制class 内容
    脚本执行,log 换行符号 PHP_EOL
    查看ip,某端口是否开启
    Out-of-core classification of text documents of sklearn
    Working With Text Data of sklearn
    docstring of python
    Manifold learning of sklearn
  • 原文地址:https://www.cnblogs.com/developer-ios/p/4917636.html
Copyright © 2020-2023  润新知