UITableviewCell GetCell未被调用

时间:2017-12-01 12:16:32

标签: c# ios uitableview xamarin

我正在使用Visual Studio Community 2017 for Mac。我有UITableview名为 SchoolSchedule 。我从按钮设置Source,但是当我点击 GetCell 按钮时,不会调用 RowsInSection 。 这是我的班级:

 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;
    }



}

这是我的按钮代码:

 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;

    }

我已经检查过,我的服务中有数据。所以这不是问题。有人可以帮忙吗?

3 个答案:

答案 0 :(得分:1)

我不得不删除表并创建一个新表。 Xamarin有一个错误。

答案 1 :(得分:0)

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

答案 2 :(得分:0)

除了在.cs文件中实现IUITableViewDelegate和IUITableViewDataSource接口,调用RegisterNibForCellReuse并分配表视图的EstimatedRowHeight之外,还很容易忘记在XIB中设置数据源和表视图的委托属性。

Xcode screenshot

相关问题