在使用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. .net简单页面后台绑定下拉框,按钮,分页 后台cs文件

    二.cs文件 using System;using System.Collections.Generic;using System.Web.UI;using System.Web.UI.WebCont ...

  2. TortoiseSVN上次文件显示被锁定

    1.可以使用SVN clean up来清除锁定. 2.如果不是本目录锁定,系统提示上一层目录锁定,需要到上一层或者根目录中清除. 3.如果在根目录下都无法clean的话,一般采取的方法是另外找一个目录 ...

  3. C# 操作NPOI导入导出

    //把T_Seats中的输入导出到Excel private void button3_Click(object sender, EventArgs e) { //1.读取 string sql = ...

  4. Oracle 账户被锁定

    哎 每次安装oracle的时候总是忘了将用户解锁,结果就蛋疼了,从网上找到一个简单的解决方案 在CMD命令输出如下: sqlplus /nolog alert user system account ...

  5. sublime 插件 和free 注册码

    代码对齐: Alignment html代码补全:  Emmet CoffeeScript语法:  Better CoffeeScript css格式化:  CSS Format less语法:  L ...

  6. Effective Java实作Comparable - 就是爱Java

    当集合或数组内的对象需要排序时,会利用Collections.sort或Arrays.sort来进行排序,通常会implement Comparable,来实现自定义排序,透过回传值来表示排序的大小. ...

  7. layout cannot be resolved or is not a field

    去除代码activity代码页面顶部中的 import android.R;这句就可以消除红色波浪线的main cannot be resolved or is not a field类似这个错误了

  8. PowerShell中的输出

    1 输出重定向 >  或者>> 2 输出控制 out-* -paging#分页输出 get-process | out-host -paging more指令用于屏显 get-pro ...

  9. shell操作mysql

    参考: http://blog.csdn.net/hbcui1984/article/details/5125387

  10. android UI之Shape详解_GradientDrawable

    在Android开发过程中,经常需要改变控件的默认样式, 那么通常会使用多个图片来解决.不过这种方式可能需要多个图片,比如一个按钮,需要点击时的式样图片,默认的式样图片. 这样就容易使apk变大. 那 ...