gpt4 book ai didi

iphone - UIScrollView 问题 : forbid to "scroll to empty space"

转载 作者:行者123 更新时间:2023-11-29 11:10:37 25 4
gpt4 key购买 nike

我有 3 个页面的 UIScrollView。我很难解释我的问题,这就是为什么我会尝试通过与 TableView 进行比较来解释它。

当您有表格 View 时,您可以滚动查看不存在的空间。我的意思是,如果您看到 1 个单元格,您可以向下滚动并看到没有单元格的空白区域。我不知道定义,所以我将其称为“滚动到空白区域”。

现在是问题。我想实现以下内容:当用户看到一页时,他不能“滚动到空白区域”,当用户在最后一页时,他可以“滚动到空白区域”

我的代码是:

    self.scroll = [[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)] autorelease];
scroll.pagingEnabled = YES;
scroll.showsHorizontalScrollIndicator = NO;
scroll.showsVerticalScrollIndicator = NO;
scroll.scrollsToTop = NO;
scroll.delegate = self;
scroll.contentSize = CGSizeMake(size.width * kNumberOfPages, size.height);
scroll.backgroundColor = [UIColor greenColor];

我应该设置哪些属性来提供所需的功能。

最佳答案

这就是所谓的弹跳。

UIScrollView有一个名为 bounces 的属性,您可以将其设置为 NO 以防止它弹跳:

    scroll.bounces = NO;

bounces

A Boolean value that controls whether the scroll view bounces past the edge of content and back again.

        @property(nonatomic) BOOL bounces

Discussion

If the value of this property is YES, the scroll view bounces when it encounters a boundary of the content. Bouncing visually indicates that scrolling has reached an edge of the content. If the value is NO, scrolling stops immediately at the content boundary without bouncing. The default value is YES.

您可以将该属性的值设置为滚动委托(delegate) – scrollViewDidScroll: 方法中所需的值。

关于iphone - UIScrollView 问题 : forbid to "scroll to empty space",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11755125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com