ios 如何让 UITableView 停止滚动
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10198315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I make a UITableView stop scrolling
提问by MusiGenesis
I don't mean that I want to disable scrolling. I want to be able to programmatically tell the table to immediately stop moving (but then it should still be scrollable after than). Is this possible?
我并不是说我想禁用滚动。我希望能够以编程方式告诉表格立即停止移动(但之后它应该仍然可以滚动)。这可能吗?
回答by ndfred
A UITableView
is a subclass of UIScrollView
. If you tell it to scroll to its current position, it will stop scrolling so this should work for you:
AUITableView
是 的子类UIScrollView
。如果您告诉它滚动到当前位置,它将停止滚动,因此这对您有用:
[tableView setContentOffset:tableView.contentOffset animated:NO];
回答by catanore
Bind your table view to a variable called tableView
, then with the following line you can disable the scrolling in Objective-C:
将您的表视图绑定到一个名为 的变量tableView
,然后使用以下行您可以禁用 Objective-C 中的滚动:
tableView.scrollEnabled = NO;
Swift version:
迅捷版:
tableView.isScrollEnabled = false
Set it to YES
(true
), if you want it to be scrollable again.
如果您希望它再次可滚动,请将其设置为YES
( true
)。
回答by Himanshu padia
set tableView.alwaysBounceVertical = false;
放 tableView.alwaysBounceVertical = false;
回答by VJVJ
If you are using table view controller,follow below steps
如果您使用的是表格视图控制器,请按照以下步骤操作
- Select table view controller on storyboard
- Go to attribute inspector->scrollview
- Uncheck the scrolling enabled
- 在情节提要上选择表视图控制器
- 转到属性检查器->滚动视图
- 取消选中滚动启用