为什么选择器需要数据源?

发布于 2024-07-16 08:26:00 字数 49 浏览 3 评论 0原文

据我了解,Pickers 有一个 Delegate 类。 为什么需要额外的数据源?

As I understand, Pickers have an Delegate class. Why's there an additional Datasource needed?

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

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

发布评论

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

评论(4

你丑哭了我 2024-07-23 08:26:00

委托和数据源之间存在差异。

数据源通常用于配置控件显示的内容。 “你有多少行?”,“我应该在这一行显示什么”,等等。

委托通常用于让控制代码知道发生了一些事情。 “嘿,有人选择了这一行。”,“嘿,有人开始编辑这一行。”

There is a difference between a delegate and a datasource.

A datasource is typically used to configure what is displayed by a control. "How many rows do you have?", "What should i display in this row", etc.

A delegate is usually used to let the controlling code know that something happened. "Hey someone selected this row.", "Hey someone started editing this row."

江湖正好 2024-07-23 08:26:00

因为选择器视图需要有关如何填充每个段内的表的信息。

有时,让一个类处理数据的来源,让另一个类处理如何处理数据可能会很有用(MVC 模式)

Because the picker view needs information on how to populate the table inside each segment.

Sometimes it may be useful to have one class handling where the data comes from and another handling what to do with it (MVC pattern)

很酷不放纵 2024-07-23 08:26:00

像大多数主管一样,挑选员很愚蠢。 它不知道要做什么,所以它不断地被给予数据和任务(由提供者); 但它需要有人知道如何处理它。 这就是代表。

Like most supervisors, the picker is stupid. It can't figure out what to work on, so it keeps being given data and tasks(by the provider); but it needs to have someone who knows what to do with it. That's the delegate.

抹茶夏天i‖ 2024-07-23 08:26:00

API 用于将数据源和委托方法组合到一个协议中(至少对于 UITableViews 而言),但它不灵活 - 现在您可以让一个完全不同的对象提供要从负责处理数据的代码中显示的数据。使用选择器的机制。

一般来说,您最终会将两者连接到同一个对象。

The API used to combine datasource and delegate methods into one protocol (at least for UITableViews), but it's inflexible - the way it is now you can have a totally different object provide the data to be displayed from the code that is responsible for handling the mechanics of using a picker.

Generally though you do end up wiring both to the same object.

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