如何管理滚动组件中的内存?

发布于 2024-12-12 02:57:56 字数 235 浏览 0 评论 0原文

除了 Cocoa 中使用的回收单元之外,是否有已知且经过验证的方法来使用表格或网格等滚动组件来管理内存?使这种布局视图的方式有效所需的计算和数据源/委托调用的顺序,但也使得协调复杂的动画与单元格和滚动视图容易出错,因为您必须在重新加载数据时仔细注意调用的顺序,滚动到影响动画目标帧的布局的偏移量和其他机制。我正在寻找一种更具声明性的方法来向滚动视图提供内容,并让它找出一种智能方法来管理其内存,就像浏览器在加载带有长垂直布局的图片的 DOM 时所做的那样。

Are there known and proven ways to manage memory with scrolling components like tables or grids other than recycling cells as is used in Cocoa? The sequence of calculations and datasource/delegation calls needed to make this way of laying out views works but also makes coordinating complex animations with the cells and a scroll view error prone as you have to pay careful attention to the sequence of calls as it reloads data, scrolls to an offset and other mechanisms of the layout that affect the target frame of your animations. I am looking for a more declarative approach to providing content to the scroll view and having it figure out a smart way to manage it's memory as is done by a browser when you load the DOM with a long vertical layout of pictures.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧话新听 2024-12-19 02:57:56

我发现创建自己的自定义布局类更容易,这些类只在我的视图上进行布局,而不是强加复杂的协议,例如 NSTableViewDataSource 等,这使得动画难以编程。我喜欢随时确切地知道我的视图在哪里,每个视图的完整层次结构,并且我不喜欢使模型与我的视图保持同步,因此我将数据存储在视图本身上。在我看来,屏幕上的对象是我作为程序员喜欢编排的唯一对象。我希望像游戏程序员一样对它们进行直接声明性控制。通过直接子类化滚动视图并遵循 Cocoa 正常 layoutSubviews 方法之外的非常简单的布局规则以避免意外布局,我能够更好地控制动画并制作更复杂和流畅的动画。希望这能激励有人也这样做。

I found it easier to create my own custom layout classes that only do layout on my views and not to impose an elaborate protocol such as NSTableViewDataSource and the like that makes animation difficult to program. I like to know exactly where my views are at all times, the complete hierarchy of each view and I don't like to keep a model in sync with my views so I store data on the views themselves. In my mind the objects on screen are the one and only objects I like to orchestrate as a programmer. I want direct declarative control over them kind of like a game programer. By subclassing a scroll view directly and following very simple layout rules outside of the normal layoutSubviews methods of Cocoa to avoid surprise layouts, I was able to control my animations better and do more complex and fluid animations. Hope this inspires someone to do the same.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文