SwiftUI中的List是否会重用类似于UITableView的单元格? [英] Does the List in SwiftUI reuse cells similar to UITableView?

查看:193
本文介绍了SwiftUI中的List是否会重用类似于UITableView的单元格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SwiftUI创建动态列表. SwiftUI List容器是否会重用类似于UITableView的单元格?

I am working on creating a dynamic list using SwiftUI. Does the SwiftUI List container reuse the cells similar to UITableView?

推荐答案

是的,List正在重用其ListCoreCellHost,就像UITableView重用其UITableViewCell的方式一样.

Yes, List is reusing its ListCoreCellHosts exactly like the way UITableView reuses its UITableViewCells.

参考:

使用Xcode调查内存使用情况表明,当项目数量一次超过List可能显示的数量时,它会尽可能显示尽可能多的内容,并在它们从顶部或底部被遮挡时重新使用它们. list.

Investigating memory usage with Xcode shows that, when the number of the items is more than List could present at once, it just shows as much as it can and reuses them when they become occluded from the top or bottom of the list.

通过跟踪单个单元的内存地址,您可以看到它一遍又一遍地被重用. 另一个令人兴奋的花絮是ListCoreCellHost使用的托管视图可能在内部引用UIKit. (不为人所知,因为它缺少文档)

By tracing a single cell memory address, you can see it is reused over and over. Another exciting tidbit is that ListCoreCellHost uses a hosting view that may refer to UIKit internally. (Not known well because it lacks documentation)

这篇关于SwiftUI中的List是否会重用类似于UITableView的单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆