一點一滴,編程人生

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            69 隨筆 :: 0 文章 :: 25 評論 :: 0 Trackbacks

          在使用UIScrollView和它的子類UITableView時,有時需要在不同操作狀態下,做不同的響應。

          如何截獲這些狀態,如正在滾動,滾動停止等,使用UIScrollViewDelegate_Protocol


          @interface SampleClass: UITableViewController<UIScrollViewDelegate> {

          ...

          }

          ...

          @end


          @implement SampleClass

          ...

          #pragma mark -
          #pragma mark UIScrollViewDelegate

          // 觸摸屏幕來滾動畫面還是其他的方法使得畫面滾動,皆觸發該函數
          - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
              NSLog(@"Scrolling...");
          }

          // 觸摸屏幕并拖拽畫面,再松開,最后停止時,觸發該函數
          - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
              NSLog(@"scrollViewDidEndDragging  -  End of Scrolling.");
          }

          // 滾動停止時,觸發該函數

          - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
              NSLog(@"scrollViewDidEndDecelerating  -   End of Scrolling.");
          }

          // 調用以下函數,來自動滾動到想要的位置,此過程中設置有動畫效果,停止時,觸發該函數

          // UIScrollView的setContentOffset:animated: 

          // UIScrollView的scrollRectToVisible:animated:

          // UITableView的scrollToRowAtIndexPath:atScrollPosition:animated:

          // UITableView的selectRowAtIndexPath:animated:scrollPosition:

          - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
              NSLog(@"scrollViewDidEndScrollingAnimation  -   End of Scrolling.");
          }

          @end

          posted on 2012-04-12 16:57 writegull 閱讀(7677) 評論(0)  編輯  收藏 所屬分類: iphone
          主站蜘蛛池模板: 鹤壁市| 汽车| 武夷山市| 六枝特区| 宁国市| 旅游| 平罗县| 道真| 景宁| 兴隆县| 左权县| 西丰县| 福清市| 曲沃县| 馆陶县| 乌苏市| 绥江县| 寿宁县| 台南县| 资源县| 北宁市| 府谷县| 武陟县| 张掖市| 莱芜市| 香格里拉县| 灵山县| 精河县| 吉水县| 凤翔县| 西丰县| 三明市| 惠来县| 湟源县| 栾城县| 德清县| 安义县| 锡林浩特市| 招远市| 北宁市| 秦皇岛市|