UITableView自定义滚动条 [英] UITableView Custom Scrollbar

查看:121
本文介绍了UITableView自定义滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为UITableView创建自定义滚动条?

我想删除默认值,该默认值在跟踪开始时弹出,而在跟踪结束时消失.相反,我希望有一个类似于计算机程序中的程序:(a)它位于屏幕的右侧,并且永久可见; (b)手动滚动条将UITableView滚动到合适的位置; (c)滚动UITableView将适当地滚动滚动条(不显示Apple提供的默认滚动条).

I want to remove the default one that pops up when tracking begins and that disappears when tracking ends. I want, instead, to have one similar to that in a computer program: (a) it's on the right side of the screen and permanently visible; (b) manually scrolling the bar will scroll the UITableView to the appropriate position; (c) scrolling the UITableView will scroll the scroll bar appropriately (without showing the default one that Apple provides).

据我所知,(b)和(c)的困难在于,Apple仅提供了滚动到特定行/节的方法,而没有滚动到下一行的四分之三的方法.因此,例如,如果我要滚动滚动条,则UITableView随后将仅滚动到行/单元格的顶部.我在说的方法是:

The difficulty in (b) and (c) is that, as far as I know, Apple only provides methods to scroll to a particular row/section, but not to scroll to three-fourths of the way down a row. So, for example, if I want to scroll the scroll bar, the UITableView will subsequently only scroll to the top of a row/cell. The method I'm talking about is:

- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated


有人以前在UITableView中实现过自定义滚动条吗?或者有人可以帮助我找出解决以下问题的方法:


Has anyone implemented a custom scroll bar in their UITableView before? Or can someone help me figure out a way to solve the following problems:

  • 滚动到UITableView中的任意点,而不是单元格的开头

  • scrolling to any point in the UITableView instead of to the start of a cell

删除默认滚动条并阻止其显示

removing the default scroll bar and preventing it from appearing

在滚动UITableView时更改滚动条图像/动画/任何内容

changing the scroll bar image/animation/whatever as the UITableView is scrolled

谢谢!

推荐答案

UITableView继承自UIScrollView,这意味着您可以使用任何现有功能.就您而言

UITableView inherits from UIScrollView, that means you can use any of the existing functions. In your case

应该做的工作.它将桌子移动到您想要的任何位置.

should do the job. It moves the table to any position you want.

要禁用现有的滚动指示器,请使用

To disable the existing scroll indicator, use

table.showsVerticalScrollIndicator = NO;

要添加您自己的视图,只需添加您的自定义视图!

And to add your own, just add your custom view!

这篇关于UITableView自定义滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆