0

我正在尝试构建一种方法来使用不同的组件动态初始化视图。因此,我需要在初始化时即时执行此操作。我正在考虑使用具有默认值的结构,如果在任何给定时间BOOL启用更改的属性,我可以重新加载输入视图。

因此,我可以遍历BOOL属性并检查是否发生了变化。有没有更好的方法来做到这一点,或者这听起来对吗?

架构:

UIView -> 按钮 1 到 10 等距放置。根据用户的喜好,可以打开/关闭按钮,但默认情况下它们都是打开的。

4

1 回答 1

0

You can use key value coding observer to identify when a value has changed. This could be your trigger to do the necessary update. Polling a boolean value for changes is an unnecessary step and might cause your app to become unresponsive. Also, evaluate if the action that causes the necessity to update/change the view is an action, then you can just implement the changes inside the proper action. For more information, check the Key-Value Observing Programming Guide : http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html

于 2012-08-09T18:16:12.270 回答