一點一滴,編程人生

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

          在使用UIScrollView和它的子類UITableView時,有時需要在不同操作狀態(tài)下,做不同的響應(yīng)。

          如何截獲這些狀態(tài),如正在滾動,滾動停止等,使用UIScrollViewDelegate_Protocol


          @interface SampleClass: UITableViewController<UIScrollViewDelegate> {

          ...

          }

          ...

          @end


          @implement SampleClass

          ...

          #pragma mark -
          #pragma mark UIScrollViewDelegate

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

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

          // 滾動停止時,觸發(fā)該函數(shù)

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

          // 調(diào)用以下函數(shù),來自動滾動到想要的位置,此過程中設(shè)置有動畫效果,停止時,觸發(fā)該函數(shù)

          // 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 閱讀(7672) 評論(0)  編輯  收藏 所屬分類: iphone
          主站蜘蛛池模板: 叶城县| 汝城县| 枣阳市| 繁昌县| 高平市| 伽师县| 吴江市| 尉犁县| 宁蒗| 和平区| 临安市| 祁东县| 大冶市| 醴陵市| 盐山县| 平陆县| 泰安市| 兰西县| 太保市| 龙门县| 镇江市| 永善县| 元朗区| 瑞昌市| 黄平县| 泰顺县| 辰溪县| 逊克县| 开化县| 湖南省| 神农架林区| 宝丰县| 浦县| 绵阳市| 沈丘县| 台安县| 唐海县| 松桃| 临高县| 远安县| 手游|