简体   繁体   中英

iOS UITableView how to disable scroll to bottom bouncing

I want to disable any scroll bouncing on my 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

在此输入图像描述

This can also be done programmatically by setting the alwaysBounceVertical property to NO

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

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

UITableView is a subclass of UIScrollView. UIScrollView has a property you can set to stop the bouncing.

In fact there are two you could use:

set the BOOL value of bounces to NO .

set the BOOL value of alwaysBounceVertical to NO .

Here's the link to the docs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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