swift - 如何在 SWIFT 中更改 ViewController 后保留集合视图滚动位置
问题描述
问题是:滚动collectionView 并单击一个项目后,另一个viewController 通过navigationController 呈现。当我点击“返回”按钮(左上角)时,集合视图会滚动到顶部,但我希望它保持更改视图控制器之前的“滚动位置”。
我尝试添加
自动AdjustsScrollViewInsets = false
谢谢
解决方案
automaticallyAdjustsScrollViewInsets
has nothing to do with what you are dealing with.
The collectionView should not scroll back to top by itself. You are probably calling reloadData()
in viewDidAppear
or viewWillAppear
which triggers the behavior you are describing.
推荐阅读
- javascript - 将 Wordpress 简码附加到 CSS 类
- android - 在应用程序启动时将 Keystore 密钥加载到内存中,或者在每次加密/解密时从 Keystore 中检索它?
- java - 我如何知道我的应用程序何时已被卸载或正在被卸载,以便我可以从我的数据库中删除相关内容?
- php - 匹配文本后跟多个带空格的换行符
- javascript - visnetwork 节点标题中的闪亮动作按钮
- c# - ASP.NET MVC 应用程序中的 IIS 服务器 MIME 错误
- reactjs - 如何使用组件方法测试状态变化
- c# - 如何配置 quickfix/n 故障转移
- javascript - 不知何故,我的数据的每一秒元素都会被删除(我需要删除循环中的每个元素)
- linux - 如何触发 Git-webhook 以通过 Jenkinsfile 将任何受保护的 github 分支合并到测试分支?