在使用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

UIScrollView 代理方法的更多相关文章

  1. iOS UIScrollview代理方法

    方法&&属性: // 监控目前滚动的位置(默认CGPointZero) CGPoint contentOffset; - (void)setContentOffset:(CGPoint ...

  2. UIScrollView代理方法

    手拖拽后会调用 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView [scrollView setContentOffset ...

  3. IOS UIScrollView常用代理方法

    iOS UIScrollView代理方法有很多,从头文件中找出来学习一下 //只要滚动了就会触发 - (void)scrollViewDidScroll:(UIScrollView *)scrollV ...

  4. UIScrollView的基本使用和一些常用代理方法

    - (void)viewDidLoad { [super viewDidLoad]; scrollView = [[UIScrollView alloc] initWithFrame:CGRectMa ...

  5. ios开发UI篇—UIScrollView属性及其代理方法

    一.UIScrollView是什么? 1.UIScrollView是滚动的view,UIView本身不能滚动,子类UIScrollview拓展了滚动方面的功能. 2.UIScrollView是所有滚动 ...

  6. UIScrollView的代理方法(delegate)

    // ViewController.m // 05-UIScrollView的代理(delegate) #import "ViewController.h" @interface ...

  7. UITableView表格视图、UITableView代理方法及应用

    一.基本知识点 UITableView表格视图,是一个可以滚动的界面(理解为垂直滚动的UIScrollView),可展示多行数据,没有行数的限制,只能有一列. 使用UITableView: 1.展示信 ...

  8. iosUIScrollView以及UIPageControl的基本使用以及所有代理方法

    //创建ScrollView的方法 -(void)createScrollView { UIScrollView *sv = [[UIScrollView alloc]initWithFrame:CG ...

  9. iOS--UIScrollView基本用法和代理方法

    主要是为了记录下UIScrollView的代理方法吧 在帮信息学院的学长做东西的时候需要大量用到分块浏览,所以就涉及到很多的关于scrollview,所以也就有了这篇文章   - (void)view ...

随机推荐

  1. Objective-C文件和目录操作,IOS文件操作,NSFileManager使用文件操作

    http://blog.csdn.net/swingpyzf/article/details/15185767

  2. JSP 实现 之 调用java方法实现MySQL数据库备份和恢复

    package cn.qm.db; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.IOEx ...

  3. POJ1671 动态规划

    POJ1671 问题重述: 本题求解一首N行诗可能的押韵结构的数目.所谓押韵结构,指的是指定的行数之间必须押韵.例如一首3行诗的押韵结构可以是aaa, aab, aba, baa, abc 5种(aa ...

  4. Lonely Integer

    https://www.hackerrank.com/challenges/lonely-integer def main(): n = int(raw_input()) s = dict() a = ...

  5. Sherlock and Squares

    //Link https://www.hackerrank.com/challenges/sherlock-and-squares from math import sqrt # 用什么,引什么,减少 ...

  6. Largest Rectangle in a Histogram(HDU 1506 动态规划)

    Largest Rectangle in a Histogram Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  7. 每次从vss获取文件都是只读

    在 Visual Studio 2008 中,使用 VSS 作为源码管理器,把文件签入后,文件会自动变为只读状态.在公司习惯是在某个开发人员的机器上获取最新的代码后编译,编译完之后服务器上再从 VSS ...

  8. JavaWeb学习笔记--HttpServletRequest、HttpServletResponse对象常用方法

    HttpServletRequest HttpSession session = request.getSession(true); //获取会话对象 Cookie[] cookies = reque ...

  9. Scala学习文档-列表的使用

    注:列表是不可变的,不能通过赋值改变列表的元素 列表具有递归结构,数组是连续的 scala里的列表类型是协变的?  --> scala中的逆变与协变 分治原则 //自定义实现:::操作符 def ...

  10. SpringMVC整合极光推送报错ClassNotFound

    问题: 今天在做后台和极光整合的过程中,将极光部分代码整合到Dao层,在启动项目的过程中总是报错,classNotFund cn/jpush/api/push/xxxx 极光官方文档: http:// ...