brandon
brandon

Reputation: 73

UITableviewCell GetCell is not being called

I am using Visual Studio Community 2017 for Mac. I have a UITableview named SchoolSchedule. I am setting the Source from a button, but then when I click the button GetCell is not called, however, RowsInSection is called. 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?

Upvotes: 3

Views: 1360

Answers (3)

Gary Meyers
Gary Meyers

Reputation: 154

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.

Xcode screenshot

Upvotes: 0

Student Michal Wloga
Student Michal Wloga

Reputation: 181

I had the same problem and I managed to fix it setting up Identifier property of TableView first prototype row - in storyboard

Upvotes: 0

brandon
brandon

Reputation: 73

I had to deleted the table and make a new one. there a bug in Xamarin.

Upvotes: 1

Related Questions