简体   繁体   English

iOS UITableView如何禁用滚动到底部弹跳

[英]iOS UITableView how to disable scroll to bottom bouncing

I want to disable any scroll bouncing on my UITableView. 我想在我的UITableView上禁用任何滚动弹跳。 For now I do it like that: 现在我这样做:

myTableView.bounces = NO;

But when I scroll to bottom of my list my content dont stop but back a little bit. 但是当我滚动到我的列表底部时,我的内容不会停止,而是回过头来。 How to disable this? 如何禁用此功能?

Just uncheck the Bounce Vertically property of UITableView 只需取消选中UITableView的Bounce Vertically属性即可

在此输入图像描述

This can also be done programmatically by setting the alwaysBounceVertical property to NO 这也可以通过将alwaysBounceVertical属性设置为NO来以编程方式完成

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView.contentOffset.y<=0) {
        scrollView.contentOffset = CGPointZero;
    }
}

UITableview是从UIScrollview继承的。所以只需使用滚动视图委托。我们可以做同样的事情,我们正在为scrollview做。如果我错了,请纠正我。

UITableView is a subclass of UIScrollView. UITableView是UIScrollView的子类。 UIScrollView has a property you can set to stop the bouncing. UIScrollView有一个属性,您可以设置为停止弹跳。

In fact there are two you could use: 事实上你可以使用两种:

set the BOOL value of bounces to NO . bouncesBOOL值设置为NO

set the BOOL value of alwaysBounceVertical to NO . alwaysBounceVerticalBOOL值设置为NO

Here's the link to the docs. 这是文档的链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM