如何在UITableView中显示滚动条
我想显示某种指示来引导用户滚动。
通常,当我们触摸 UITableView 时,如果需要,就会出现滚动条。但我希望这个滚动条指示已经显示在我的表格视图上。
怎么可能这样做呢?
I want to display some kind of indication to guide user to scroll.
Usually when we touch the UITableView scrollbar appears if needed. But I want this scrollbar indication already displayed on my tableview.
How is it possible to do so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您有一个超出屏幕的表格视图,您可以调用
[self.tableView flashScrollIndicators];
,它们会闪烁以向用户表明它们在那里。这通常放在 viewDidAppear 中。
(如果您继承自 UITableViewController,那么您将有一个 self.tableView 实例变量,如果没有,则替换另一个 UITableView。)
如果滚动视图的整个内容适合其视图,则不会显示滚动条;为了测试这一点,显示一个只有一个单元格的表格视图。如果内容大小大于视图的框架,则会显示滚动条;只有这样
[self.tableView flashScrollIndicators];
才会真正闪烁滚动指示器。If you have a table view that goes offscreen, you can call
[self.tableView flashScrollIndicators];
and they will flash to show the user that they are there. This is usually put in viewDidAppear.
(If you inherit from UITableViewController then you will have a self.tableView instance variable, if not then substitute another UITableView.)
If you a scroll view's entire contents fit within its view then no scroll bars are displayed; to test this display a table view with only one cell. If the content size is larger than the view's frame then scroll bars will be displayed; only then will
[self.tableView flashScrollIndicators];
actually flash scroll indicators.没有办法强制滚动条出现,除非弄乱 UITableView 的内部(你不应该这样做),或者重新设计你自己的表视图类。
根据 UIScrollView 的文档 showsVerticalScrollIndicator 属性:“跟踪正在进行时指示器可见,跟踪后淡出。”
There's no way to force the scrollbar to appear, short of messing with the internals of UITableView(which you shouldn't do), or redesigning your own table view class.
Per the documentation of UIScrollView's showsVerticalScrollIndicator property: "The indicator is visible while tracking is underway and fades out after tracking."