Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UITableView滚动指示器不会隐藏在顶部或底部_Iphone_Objective C_Ios - Fatal编程技术网

Iphone UITableView滚动指示器不会隐藏在顶部或底部

Iphone UITableView滚动指示器不会隐藏在顶部或底部,iphone,objective-c,ios,Iphone,Objective C,Ios,我对UITableView有问题。在以下情况下,它不会隐藏滚动指示器: 1快速滚动 然后击中桌子的顶部或底部 这是一个截图 如何确保滚动指示器按预期正确隐藏 请注意,反弹是关闭的。我也不想只是隐藏滚动指示器,我只想它消失时,滚动停止在顶部或底部预期 编辑:此问题似乎是由于将视图控制器设置automaticallyAdjustsScrollViewInsets设置为false引起的。似乎需要设置以下3项才能重现问题: 1需要关闭“表视图反弹” 2视图控制器设置automaticallyAdjust

我对UITableView有问题。在以下情况下,它不会隐藏滚动指示器:

1快速滚动

然后击中桌子的顶部或底部

这是一个截图

如何确保滚动指示器按预期正确隐藏

请注意,反弹是关闭的。我也不想只是隐藏滚动指示器,我只想它消失时,滚动停止在顶部或底部预期

编辑:此问题似乎是由于将视图控制器设置automaticallyAdjustsScrollViewInsets设置为false引起的。似乎需要设置以下3项才能重现问题:

1需要关闭“表视图反弹”

2视图控制器设置automaticallyAdjustsScrollViewInsets为false这是为了解决一个不同的问题,其中滚动指示器看起来根本不正确

3 UIViewController本身的视图不应是表视图,表视图必须是子视图

在viewDidLoad中,将显示如下内容:

self.view_table = [[UITableView alloc] initWithFrame:self.view.frame];
self.view_table.bounces = false;
self.automaticallyAdjustsScrollViewInsets = false;

此外,表视图的内容需要大于其框架的高度。

执行以下步骤

去锡伯 选择相应的表 转到属性并禁用水平和垂直滚动条。
UITableView继承自UIScrollView,因此您需要使用UIScrollView的属性:

Property: showsVerticalScrollIndicator
A Boolean value that controls whether the vertical scroll indicator is visible.
看看。

试试这个:

-(void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset{
    if (!scrollView.bounces) {
        targetContentOffset->y = -1;//Scrollbar does not move here, because bounces is disabled, but scrollbar can hidden.
    }
}

我有一个答案是基于范亚楠.

在UITableViewDelegate中: 目标C:

Swift 4:

如果表格视图滚动到顶部或底部,此代码将使其在非常近的位置停止,但不会在最后完全停止。这允许滚动指示器消失。

在viewwillLoad中 使tableView.showsVerticalScrollIndicator=false


要在tableView的“滚动动作”视图中禁用滚动指示器,是否确实要禁用?我需要卷轴。谢谢这个回答误解了问题。老兄,我需要显示滚动条,但它们有时会在顶部和底部冻结。我不需要事先把它们藏起来,我不明白这一点。然后看一看滚动指示符号集。这个答案误解了问题。1你应该解释一下,如何处理这个代码。2内联代码应该使用``反勾号,多行代码应该使用四个空格,看不出确切的答案,但我认为滚动视图/表视图是一个长期存在的错误。如果打开“反弹”,滚动指示器将正常工作。此代码主要适用于我,但我必须将偏移因子设置为1。使用0.01或-1对我不起作用。在顶部,0.25似乎有效,但在底部,它必须是0.5。为了安全,我把它设为1。这可能与设备屏幕分辨率或scrollView的帧大小有关。我正在用iOS 11测试iPadMini4。奇怪的是,当我拉下scrollView时,我可以看到它向下移动,看起来像是1个像素。我的scrollView/CollectionView也会水平滚动。我最近不得不再次使用此代码,并准确地找到了您所说的内容。我不知道一个像素运动的方法。
-(void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset{
    if (!scrollView.bounces) {
        if(targetContentOffset->y <= 1)
        {
            targetContentOffset->y = 0.01;
        }
        else if(targetContentOffset->y >= scrollView.contentSize.height - scrollView.height)
        {
            targetContentOffset->y = scrollView.contentSize.height - scrollView.height - 0.01;
        }
    }
}
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
    guard !scrollView.bounces else {
        return
    }

    if(targetContentOffset.pointee.y <= 1)
    {
        targetContentOffset.pointee.y = 0.01;
    }
    else if(targetContentOffset.pointee.y >= scrollView.contentSize.height - scrollView.height)
    {
        targetContentOffset.pointee.y = scrollView.contentSize.height - scrollView.height - 0.01;
    }
}