gpt4 book ai didi

ios - Xamarin.iOS 中的 UITableViewController.RowsInSection(UITableView, int) 应该是什么?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:08:45 25 4
gpt4 key购买 nike

我已经对 UITableViewController 进行了子类化,并且在某些时候想找出一个部分中的行数。我想使用:

myController.TableView.NumberOfRowsInSection(2);

相反(感谢 Intellisense)我输入:

myController.RowsInSection(myController.TableView, 2);

第一个方法返回正确的行数。然而,后一个总是返回零。然后我查阅了 Apple 的文档,UITableViewController 上没有这样的方法。

这是错误还是我不明白的功能?

最佳答案

它是UITableViewDataSource 类的方法。它基本上使 UITableViewController 符合 UITableViewDataSource Obj-C 协议(protocol),它意味着被覆盖,而不是直接调用。

因此,您可以使用表 Controller 来达到同样的目的,而不是为表源创建一个单独的类。

例子:

// Inside your UITableViewController subclass.
// Instead of this:
//this.TableView.Source = new MyTableSource();
// You can do this:
this.TableView.WeakDataSource = this;
this.TableView.WeakDelegate = this;

关于ios - Xamarin.iOS 中的 UITableViewController.RowsInSection(UITableView, int) 应该是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20750659/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com