禁止scrollView滚动

来源:互联网 发布:浙师大行知学院迎新网 编辑:程序博客网 时间:2024/05/21 22:57

1. 禁止上下滚动

contentsize.height =0即可

2.禁止左右滚动

contentsize.width = 0即可

3.禁止滚动

contentsize.height =0; contentsize.width = 0;

但是用 scrollEnabled = NO; 更方便

4.禁止下滚动

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{    if (scrollView.contentOffset.y <= 0.0) {        CGFloat sizeWidth = scrollView.contentSize.width;        CGFloat sizeHeght = scrollView.contentSize.height;        [scrollView setContentSize:CGSizeMake(sizeWidth, 0)];        [scrollView setContentSize:CGSizeMake(sizeWidth, sizeHeght)];    }}

4.禁止上滚动

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{    if (scrollView.contentOffset.y >= 0.0) {        CGFloat sizeWidth = scrollView.contentSize.width;        CGFloat sizeHeght = scrollView.contentSize.height;        [scrollView setContentSize:CGSizeMake(sizeWidth, 0)];        [scrollView setContentSize:CGSizeMake(sizeWidth, sizeHeght)];    }}

1 0
原创粉丝点击