首页 > 其他 > 详细

UIScrollView 代理方法

时间:2016-01-25 16:45:55      阅读:166      评论:0      收藏:0      [点我收藏+]

在使用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 代理方法

原文:http://www.cnblogs.com/paocai2015/p/5157476.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!