主要是为了记录下UIScrollView的代理方法吧
在帮信息学院的学长做东西的时候需要大量用到分块浏览,所以就涉及到很多的关于scrollview,所以也就有了这篇文章
1 - (void)viewDidLoad 2 { 3 [super viewDidLoad]; 4 5 scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)]; 6 scrollView.backgroundColor = [UIColor redColor]; 7 // 是否支持滑动最顶端 8 // scrollView.scrollsToTop = NO; 9 scrollView.delegate = self; 10 // 设置内容大小 11 scrollView.contentSize = CGSizeMake(320, 460*10); 12 // 是否反弹 13 // scrollView.bounces = NO; 14 // 是否分页 15 // scrollView.pagingEnabled = YES; 16 // 是否滚动 17 // scrollView.scrollEnabled = NO; 18 // scrollView.showsHorizontalScrollIndicator = NO; 19 // 设置indicator风格 20 // scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite; 21 // 设置内容的边缘和Indicators边缘 22 // scrollView.contentInset = UIEdgeInsetsMake(0, 50, 50, 0); 23 // scrollView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 50, 0, 0); 24 // 提示用户,Indicators flash 25 [scrollView flashScrollIndicators]; 26 // 是否同时运动,lock 27 scrollView.directionalLockEnabled = YES; 28 [self.view addSubview:scrollView]; 29 30 UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 200, 320, 40)]; 31 label.backgroundColor = [UIColor yellowColor]; 32 label.text = @"学习scrolleview"; 33 [scrollView addSubview:label]; 34 [label release]; 35 } 36 37 #pragma mark - 38 /* 39 // 返回一个放大或者缩小的视图 40 - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 41 { 42 43 } 44 // 开始放大或者缩小 45 - (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView: 46 (UIView *)view 47 { 48 49 } 50 51 // 缩放结束时 52 - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale 53 { 54 55 } 56 57 // 视图已经放大或缩小 58 - (void)scrollViewDidZoom:(UIScrollView *)scrollView 59 { 60 NSLog(@"scrollViewDidScrollToTop"); 61 } 62 */ 63 64 // 是否支持滑动至顶部 65 - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView 66 { 67 return YES; 68 } 69 70 // 滑动到顶部时调用该方法 71 - (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView 72 { 73 NSLog(@"scrollViewDidScrollToTop"); 74 } 75 76 // scrollView 已经滑动 77 - (void)scrollViewDidScroll:(UIScrollView *)scrollView 78 { 79 NSLog(@"scrollViewDidScroll"); 80 } 81 82 // scrollView 开始拖动 83 - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView 84 { 85 NSLog(@"scrollViewWillBeginDragging"); 86 } 87 88 // scrollView 结束拖动 89 - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate 90 { 91 NSLog(@"scrollViewDidEndDragging"); 92 } 93 94 // scrollView 开始减速(以下两个方法注意与以上两个方法加以区别) 95 - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView 96 { 97 NSLog(@"scrollViewWillBeginDecelerating"); 98 } 99 100 // scrollview 减速停止 101 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 102 { 103 NSLog(@"scrollViewDidEndDecelerating"); 104 }