设置 setNumberRows 是否取消分配不需要的行?

Does setting setNumberRows de-allocate the unneeded rows?

我在 WatchOS 上使用 WKInterfaceTable

如果 table 已经有 5 行,

和我

.setNumberOfRows(2, withRowType: "rows") 现在只有 2 行,

这是否意味着不再可见的 3 行被解除分配

(或者我必须 运行 apptTable.removeRows 才能取消分配)?

谢谢

在您调用 .setNumberOfRows 之后,WKInterfaceTable 将被更新,所以是的,您示例中的额外 3 行将被删除。无需手动调用 removeRows。

这也明确说明了in the documentation

Use this method when you want to populate a table with rows that are all of the same type. This method removes any existing rows from the table and configures a new set of rows based on the information in the numberOfRows and rowType parameters.