简体   繁体   English

UITableviewCell GetCell未被调用

[英]UITableviewCell GetCell is not being called

I am using Visual Studio Community 2017 for Mac. 我正在使用Visual Studio Community 2017 for Mac。 I have a UITableview named SchoolSchedule . 我有一个名为SchoolScheduleUITableview I am setting the Source from a button, but then when I click the button GetCell is not called, however, RowsInSection is called. 我从一个按钮设置Source ,但是当我单击按钮时没有调用GetCell ,但是,调用了RowsInSection Here is my class: 这是我的班级:

 public class ScheduleTableViewSource : UITableViewSource
{
    private Schedule[] school;

    public ScheduleTableViewSource(Schedule[] school)
    {
        this.school = school;
    }

    public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
    {
        var cell = (ScheduleCell) tableView.DequeueReusableCell("cell_id", indexPath);
        var school1 = school[indexPath.Row];
        cell.Updatecell(school1);
        cell.TextLabel.Text = school[indexPath.Row].Site;
        return cell;
    }

    public override nint RowsInSection(UITableView tableview, nint section)
    {
        return school.Length;
    }



}

here is my button code : 这是我的按钮代码:

 partial void Get_button_TouchUpInside(UIButton sender)
    {

        bool check = NetworkInterface.GetIsNetworkAvailable();
        if(check)
        {

            Service1 client = new Service1();
            var school = client.CypressRidge("CypressRidge");
            SchoolSchedule.Source = new ScheduleTableViewSource(school);
            SchoolSchedule.ReloadData();

        }
        else{
            Console.Write("Error no Internet connection");
            return;
        }
     //   int stop =0;

    }

I have checked and there is data coming in from my service. 我已经检查过,我的服务中有数据。 so that is not the problem. 所以这不是问题。 can anyone help? 有人可以帮忙吗?

I had to deleted the table and make a new one. 我不得不删除表并创建一个新表。 there a bug in Xamarin. Xamarin中有一个错误。

我有同样的问题,我设法修复它设置TableView第一个原型行的标识符属性 - 在故事板中

In addition to implementing the IUITableViewDelegate and IUITableViewDataSource interfaces in the .cs file, calling RegisterNibForCellReuse, and assigning the table view's EstimatedRowHeight, it's easy to forget to set the data source and delegate properties of the table view in the XIB. 除了在.cs文件中实现IUITableViewDelegate和IUITableViewDataSource接口,调用RegisterNibForCellReuse,并分配表视图的EstimatedRowHeight之外,很容易忘记在XIB中设置表视图的数据源和委托属性。

Xcode截图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM