UIScrollView的屬性總結

  UIScrollView的屬性總結
  
 
屬性 TableView 做用

separatorStyleapp

分割線

rowHeightpost

行高
   
   
   
 
 
屬性 做用
CGPoint contentOffSet 監控目前滾動的位置
CGSize contentSize 滾動範圍的大小
UIEdgeInsets contentInset 視圖在scrollView中的位置

id<UIScrollerViewDelegate> delegate動畫

//--視圖拖拽時結束 鍵盤編輯窗口(若是窗口存在的話)ui

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollViewspa

 

設置協議
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,若是:rest

1.  150ms內若是你的手指沒有任何動做,消息就會傳給subView。code

2.  150ms內手指有明顯的滑動(一個swipe動做),scrollView就會滾動,消息不會傳給subView,這裏就是產生問題二的緣由。orm

3. 150ms內手指沒有滑動,scrollView將消息傳給subView,可是以後手指開始滑動,scrollView傳送touchesCancelled消息給subView,而後開始滾動。blog

觀察下tableView的狀況,你先按住一個cell,cell開始高亮,手不要放開,開始滑動,tableView開始滾動,高亮取消。

 

delaysContentTouches的做用:

這個標誌默認是YES,使用上面的150ms的timer,若是設置爲NO,touch事件當即傳遞給subView,不會有150ms的等待。

 

cancelsTouches的做用:

這個標準默認爲YES,若是設置爲NO,這消息一旦傳遞給subView,這scroll事件不會再發生。

相關文章
相關標籤/搜索