IOS--UIScrollView delegate 协议-
来源:互联网 发布:淘宝网免费下载 编辑:程序博客网 时间:2024/05/01 09:36
以下为该协议的相关方法:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
{
// NSLog(@" scrollViewDidScroll");
NSLog(@"ContentOffset x is %f,yis %f",scrollView.contentOffset.x,scrollView.contentOffset.y);
}
//开始拖拽视图
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;
{
NSLog(@"scrollViewWillBeginDragging");
}
//完成拖拽
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;
{
NSLog(@"scrollViewDidEndDragging");
// if (scrollView.contentOffset.x <= 110) {
// [scrollView setContentOffset:CGPointMake(0, 0) animated:YES];
// [ApplicationDelegate setPlayIndex:0];
// return;
// }
// if (scrollView.contentOffset.x > ( 110 + 210 * (ApplicationDelegate.programCount-2)))
// {
// [scrollView setContentOffset:CGPointMake(210 + 210 * (ApplicationDelegate.programCount-2), 0) animated:YES];
// [ApplicationDelegate setPlayIndex:ApplicationDelegate.programCount-1];
// return;
// }
for(int i =0 ; i < ApplicationDelegate.programCount-2 ; i++){
if (scrollView.contentOffset.x > (110 + i *210) && scrollView.contentOffset.x <= ( 110 + 210 * (i+1)))
{
[scrollView setContentOffset:CGPointMake(210 +210 * i, 0) animated:YES];
[ApplicationDelegate setPlayIndex:i+1];
NSLog(@"%d" , i);
//return;
}
}
}
//将开始降速时
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView;
{
NSLog(@"scrollViewWillBeginDecelerating");
}
//减速停止了时执行,手触摸时执行执行
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;
{
NSLog(@"scrollViewDidEndDecelerating");
if (scrollView.contentOffset.x <= 110) {
[scrollView setContentOffset:CGPointMake(0,0) animated:YES];
[ApplicationDelegate setPlayIndex:0];
return;
}
if (scrollView.contentOffset.x > ( 110 + 210 * (ApplicationDelegate.programCount-2)))
{
[scrollView setContentOffset:CGPointMake(210 +210 * (ApplicationDelegate.programCount-2),0) animated:YES];
[ApplicationDelegate setPlayIndex:ApplicationDelegate.programCount-1];
NSLog(@"over");
return;
}
for(int i =0 ; i < ApplicationDelegate.programCount-2 ; i++){
if (scrollView.contentOffset.x > (110 + i *210) && scrollView.contentOffset.x <= ( 110 + 210 * (i+1)))
{
[scrollView setContentOffset:CGPointMake(210 +210 * i, 0) animated:YES];
[ApplicationDelegate setPlayIndex:i+1];
//return;
}
}
}
//滚动动画停止时执行,代码改变时出发,也就是setContentOffset改变时
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView;
{
NSLog(@"scrollViewDidEndScrollingAnimation");
}
//设置放大缩小的视图,要是uiscrollview的subview
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;
{
NSLog(@"viewForZoomingInScrollView");
return nil;
}
//完成放大缩小时调用
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale;
{
NSLog(@"scale between minimum and maximum. called after any 'bounce' animations");
}// scale between minimum and maximum. called after any 'bounce' animations
//如果你不是完全滚动到滚轴视图的顶部,你可以轻点状态栏,那个可视的滚轴视图会一直滚动到顶部,那是默认行为,你可以通过该方法返回NO来关闭它
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView;
{
NSLog(@"scrollViewShouldScrollToTop");
return YES;
}
- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView;
{
NSLog(@"scrollViewDidScrollToTop");
}
注意还要对使用的ScrollView进行属性设置
// scrollView的 长 宽 设置
self.programScrollView.contentSize=CGSizeMake(ApplicationDelegate.programCount *210+10 , 40);
// 是否分页显示
self.programScrollView.pagingEnabled=NO;
//协议
self.programScrollView.delegate=self;
// 监听手指动作
self.programScrollView.canCancelContentTouches=NO;
//延迟手指动作
self.programScrollView.delaysContentTouches=YES;
- IOS--UIScrollView delegate 协议-
- IOS UIScrollView delegate
- iOS: UIScrollView的属性delegate
- iOS UIScrollView delegate 的Bug
- ios委托delegate与协议protocol
- ios中的代理与协议(delegate)
- iOS中的协议(Protocol)与代理(Delegate)
- 【IOS沉思录】IOS中的协议Protocol与代理Delegate
- UIScrollView的代理(delegate)
- UIScrollView的代理(delegate)
- IOS系列——UIScrollview的delegate里面的方法意义
- IOS控件UIScrollView详解(基本方法、属性和delegate用法)
- 【iOS开发】协议与委托 (Protocol and Delegate) 实例解析
- iOS开发 协议与委托(Protocol and Delegate)
- 【iOS开发】协议与委托 (Protocol and Delegate)
- iOS开发】协议与委托 (Protocol and Delegate) 实例解析
- 【iOS开发】协议与委托 (Protocol and Delegate) 实例解析
- 【iOS知识学习】_协议(delegate)和类别(category)
- 共模滤波器
- java向线程中传递参数
- linux各文件夹的作用
- 山沟沟里的实业路(2)
- Managed Debugging Assistants (zz)
- IOS--UIScrollView delegate 协议-
- 查询表字段类型
- [cocos2d-x] --- CCNode类详解
- 看13位CEO、创始人和高管如何提高工作效率
- YII简单的文件下载
- ERP系统容灾方案析投入产出比例与维护管理成本分析
- C++开发者都应该使用的10个C++11特性
- 笔记
- MS是彻底抛弃makefile了,他新一代的build system 是MS Build.