按 tabbar 并在 prefersLargeTitles = true iOS 中调用 Scroll to top
Press tabbar and call Scroll to top within prefersLargeTitles = true iOS
尝试使用此代码检测用户点击选项卡栏项目然后滚动到顶部的活动控制器
if let indexPath = tableView.indexPathForRow(at: CGPoint(x: 0, y: 0)) {
tableView.scrollToRow(at: indexPath, at: .top, animated: true)
}
它工作正常,但问题是控制器以大导航栏标题启动,因此当控制器滚动到第一行时,导航栏标题不会恢复为大标题样式
navigationController?.navigationBar.prefersLargeTitles = true
使用这个:
tableView.setContentOffset(CGPoint(x: 0, y: -141), animated: true)
这里141是大标题导航栏和状态栏的尺寸(97pts + 44pts)。
尝试使用此代码检测用户点击选项卡栏项目然后滚动到顶部的活动控制器
if let indexPath = tableView.indexPathForRow(at: CGPoint(x: 0, y: 0)) {
tableView.scrollToRow(at: indexPath, at: .top, animated: true)
}
它工作正常,但问题是控制器以大导航栏标题启动,因此当控制器滚动到第一行时,导航栏标题不会恢复为大标题样式
navigationController?.navigationBar.prefersLargeTitles = true
使用这个:
tableView.setContentOffset(CGPoint(x: 0, y: -141), animated: true)
这里141是大标题导航栏和状态栏的尺寸(97pts + 44pts)。