Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin.ios 绑定到TableView Xamarin_Xamarin.ios_Xamarin - Fatal编程技术网

Xamarin.ios 绑定到TableView Xamarin

Xamarin.ios 绑定到TableView Xamarin,xamarin.ios,xamarin,Xamarin.ios,Xamarin,我正试图使用下面的代码使用Xamarin ios绑定到一个TableView,但是我运气不好,正如你所看到的,我使用parse.com作为我的datalyer var query = from gaemPlayer in ParseObject.GetQuery ("players") select gaemPlayer; myPlayers.DataSource = query; 其中,myPlayers是我在iOS designer is c中给出的表源名称,

我正试图使用下面的代码使用Xamarin ios绑定到一个TableView,但是我运气不好,正如你所看到的,我使用parse.com作为我的datalyer

  var query = from gaemPlayer in ParseObject.GetQuery ("players")
           select gaemPlayer;
  myPlayers.DataSource = query;

其中,
myPlayers
是我在iOS designer is c中给出的表源名称,我通常会使用
ToList
函数来创建一个通用列表,但Xamarin的情况并非如此。

您的源代码需要是从UITableViewSource派生的类。源类将具有确定表中每个节有多少节和行的方法,以及实际构建要显示的UITableViewCell的方法。您还可以为其他功能覆盖其他方法,但这些方法是最低限度的

请注意,不能仅使用列表作为源的原因是Xamarin正在建模Obj-C UITableView模式。构建简单表格的另一种方法是使用

公共类MySource:UITableViewSource
{
私人名单数据;
公共MySource(列表数据){
这个数据=数据;
}
公共覆盖int RowsInSection(UITableView表格视图,int section)
{
返回data.Count();
}
公共覆盖int NumberOfSections(UITableView表格视图)
{
返回1;
}
公共覆盖UITableViewCell GetCell(UITababVIEW TabLVIEW,MyLux.Posial.NSIXDEXPATH索引路径)
{
//在此处实例化并返回UITableViewCell
}

我在单元格和uimage视图中都有一个标签,从我看到的情况来看,getCell方法将是我访问这些属性的地方是的,我是对的是的,你实例化一个单元格并在getCell中设置它的属性
public class MySource : UITableViewSource
{
  private List<item> data;

  public MySource(List<Item> data) {
    this.data = data;
  }

  public override int RowsInSection (UITableView tableview, int section)
  {
    return data.Count();
  }

  public override int NumberOfSections (UITableView tableView)
  {
    return 1;
  }


  public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
  {
    // instantiate and return your UITableViewCell here
  }