我有一个应用程序,我想在其中实现可滚动属性设置为 False 的 UITableView。
我已将 UITableView 添加到 UIScrollView 中以完成此任务,现在我希望我的 UIScrollView 将其向下滚动到 UITableView 的最后一个单元格。那么,我如何为 UIScrollView 分配动态高度,以便它滚动到我的 UITableView 的最后一个单元格。
最佳答案
你真的需要 ScrollView 吗?您可以在没有 ScrollView 的情况下简单地执行此操作
tableView.scrollToRow(at: IndexPath(row: lastIndex, section: 0), at: .middle, animated: true)
或
tableView.setContentOffset(CGPoint(x: 0, y: tableView.contentSize.height - tableView.frame.height), animated: true)
另外Apple不推荐在scrollview里面添加tableview Apple style guide
Don’t place a scroll view inside of another scroll view. Doing so creates an unpredictable interface that’s difficult to control.
关于ios - UIScrollView 内不可滚动的 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56749219/