城之内

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

一、知识点简单介绍(转载自:http://www.cnblogs.com/wendingding/p/3754210.html)

1.UIScrollView控件是什么?

(1)移动设备的屏幕⼤大⼩小是极其有限的,因此直接展⽰示在⽤用户眼前的内容也相当有限

(2)当展⽰示的内容较多,超出⼀一个屏幕时,⽤用户可通过滚动⼿手势来查看屏幕以外的内容

(3)普通的UIView不具备滚动功能,不能显⽰示过多的内容

(4)UIScrollView是一个能够滚动的视图控件,可以⽤用来展⽰示⼤大量的内容,并且可以通过滚 动查看所有的内容

 (5)  举例:手机上的“设置”、其他⽰示例程序 

2.UIScrollView的简单使用

(1)将需要展⽰的内容添加到UIScrollView中

(2)设置UIScrollView的contentSize属性,告诉UIScrollView所有内容的尺⼨寸,也就是告诉 它滚动的范围(能滚多远,滚到哪⾥里是尽头) 

3.属性

(1)常用属性:

1)@property(nonatomic)CGPoint  contentOffset; 是scrollview当前显示区域顶点相对于frame顶点的偏移量

2)@property(nonatomic)CGSize  contentSize;这个属性⽤用来表⽰示UIScrollView内容的尺寸,滚动范围

3)@property(nonatomic)UIEdgeInsets contentInset; 这个属性能够在UIScrollView的四周增加额外的滚动区域 

 

BOOL directionalLockEnabled 指定控件是否只能在一个方向上滚动

BOOL bounces                      控制控件遇到边框是否反弹

BOOL alwaysBounceVertical   控制垂直方向遇到边框是否反弹

BOOL alwaysBounceHorizontal 控制水平方向遇到边框是否反弹

BOOL pagingEnabled             控制控件是否整页翻动

BOOL scrollEnabled               控制控件是否能滚动

BOOL showsHorizontalScrollIndicator 控制是否显示水平方向的滚动条

BOOL showsVerticalScrollIndicator 控制是否显示垂直方向的滚动条

UIEdgeInsets scrollIndicatorInsets 指定滚动条在scrollerView中的位置

UIScrollViewIndicatorStyleindicatorStyle 设定滚动条的样式

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                        控制控件滚动到顶部

常用接口:

- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;  // animate at constant velocity to new offset

设置contentOffset

 

- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated;         // scroll so rect is just visible (nearest edges). nothing if rect completely visible

类似设置contentOffset,不过它是设置一个CGRect

 

- (void)flashScrollIndicators    // displays the scroll indicators for a short time. This should be done whenever you bring the scroll view to front.

 

 

4.注意点

• 如果UIScrollView⽆无法滚动,可能是以下原因:

(1)没有设置contentSize

(2) scrollEnabled = NO

(3) 没有接收到触摸事件:userInteractionEnabled = NO

(4)没有取消autolayout功能(要想scrollView滚动,必须取消autolayout) 

posted on 2015-08-02 16:58  城之内  阅读(168)  评论(0编辑  收藏  举报