validateProperties()和invalidateProperties之间差()validateProperties、invalidateProperties

2023-09-08 13:48:57 作者:都是地球人为什么说不合适

任何一个可以告诉我一下 之间有什么区别 validateProperties() invalidateProperties()

Can any one tell me about what is the Difference between validateProperties() and invalidateProperties() ?

推荐答案

invalidateProperties 的:

标记组件,以便的commitProperties()方法被调用   在稍后的屏幕更新。

Marks a component so that its commitProperties() method gets called during a later screen update.

失效是消除重复工作,通过有效机制   拖延更改组件的处理,直到稍后的屏幕   更新。例如,如果要更改文本颜色和大小,   会浪费更新后立即改变它的颜色   然后更新的大小,当它被设置。它是更有效的   更改两个属性后再呈现文本使用新的大小和   颜色一次。

Invalidation is a useful mechanism for eliminating duplicate work by delaying processing of changes to a component until a later screen update. For example, if you want to change the text color and size, it would be wasteful to update the color immediately after you change it and then update the size when it gets set. It is more efficient to change both properties and then render the text with its new size and color once.

失效方法很少被调用。在一般情况下,设置属性   在组件自动调用相应的失效   方法。

Invalidation methods rarely get called. In general, setting a property on a component automatically calls the appropriate invalidation method.

validateProperties :

由布局逻辑用于通过来验证组件的属性   调用commitProperties()方法。一般情况下,子类不应   覆盖commitProperties()方法,而不是这个方法。

Used by layout logic to validate the properties of a component by calling the commitProperties() method. In general, subclassers should override the commitProperties() method and not this method.

从本质上讲,直接验证呼叫的commitProperties而无效等待下一帧做。始终使用无效。

Essentially, validate calls commitProperties directly while invalidate waits for the next frame to do it. Always use invalidate.

相关推荐