Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8073883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:28:57+00:00 2026-06-05T14:28:57+00:00

In my MonoDevelop project I have an iPhone app. I have two different views.

  • 0

In my MonoDevelop project I have an iPhone app. I have two different views. Each view contains a UITable. For view 1 I have class 1 hooked to the UITableViewController as Datasource 1. The class is specified in Interface Builder on the UITableViewController class property.

For View 2 I have a class 2 hooked up as Datasource 2. Also hooked up in interface builder on the UITableViewController class property. Both classes (i.e. Datasources) feed the tables with data. View 2 also has a custom cell and because of this loads asynchronous.

I get the data from 2 xml files using linq to xml. Everything works and the data loads great. What I need to do know is to load data in Datasource 2 based on the selection made in View 1. To do this I need to pass an ID from view 1 to Class(Datasource) 2. This works great and the data for the selected ID loads. The problem is when i tap back on the Navigation controller and change my selection (ID) on the first screen, exactly the same data is shown which tells me the UITable does not refresh with the new selection.

Datasource Code that loads the rounds (ID):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Data;

namespace CurrieCup2012
{
    [MonoTouch.Foundation.Register("FixturesTableViewController")]
    
    public partial class MyTableViewController : UITableViewController
    {
        static NSString CellID = new NSString ("MyIdentifier");
        List<Fixtures> Fixtures;
        
        // Constructor invoked from the NIB loader
        public MyTableViewController (IntPtr p) : base (p)
        {
            
        }
        
        
        // The data source for our TableView
        class DataSource : UITableViewDataSource
        {
            MyTableViewController tvc;
            
            public DataSource (MyTableViewController tableViewController)
            {
                this.tvc = tableViewController;
            }
            
            public override int RowsInSection (UITableView tableView, int section)
            {
                return tvc.Fixtures.Count;
            }

            public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
            {
                var cell = tableView.DequeueReusableCell (CellID);
                if (cell == null)
                {
                    cell = new UITableViewCell (UITableViewCellStyle.Default, CellID);
                }
            
                // Customize the cell here...
            
                Fixtures fixtures = tvc.Fixtures.ElementAt(indexPath.Row);
                cell.TextLabel.Text = fixtures.RoundID;
                
                cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
                
                return cell;
            }
        }
    
        // This class receives notifications that happen on the UITableView
        class TableDelegate : UITableViewDelegate
        {
            MyTableViewController tvc;

            public TableDelegate (MyTableViewController tableViewController)
            {
                this.tvc = tableViewController;
            }
            
            DetailFixturesViewer detailsViewController;
            //SelectedRound round = new SelectedRound();
            
            public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
            {
                if (detailsViewController == null)
                detailsViewController = new DetailFixturesViewer();
                
                Fixtures fixtures = tvc.Fixtures.ElementAt(indexPath.Row);
                //Console.WriteLine(fixtures.RoundID);
                detailsViewController.CurrentFixtures = fixtures;
                IntPtr vd;
                MyTableViewController2 mtv = new MyTableViewController2(vd);
                mtv.round = fixtures.RoundID;

            //  round.RoundID =  tvc.Fixtures.ElementAt(indexPath.Row).RoundID;
                
            
            //  Console.WriteLine("Set Selected round on row selected: " + round.RoundID);
                
                //SelectedRound selround = new SelectedRound();
                //selround.RoundID = fixtures.RoundID;
                
                SelectedRound.RoundID = fixtures.RoundID;
                    
                //Console.WriteLine(round.RoundID);
                //Console.WriteLine(indexPath.Row.ToString());
                //Console.WriteLine(newsArticle.Headline.ToString());
                //Console.WriteLine(newsArticle.Link.ToString());
                tvc.NavigationController.PushViewController(detailsViewController, true);
                tvc.NavigationController.ViewWillAppear(true);
                detailsViewController.CurrentFixtures.RoundID = fixtures.RoundID;
                detailsViewController.CurrentFixtures.Date = fixtures.Date;
                detailsViewController.Title = fixtures.RoundID;
            }
        }

        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();
            //Console.WriteLine("Linq");
            XDocument rss =
            XDocument.Load("http://curriecup.dutch-vegas.com/XML/rounds.xml");
            
            var query = from item in rss.Descendants("Round")
                select new Fixtures 
                       {
                            RoundID = "Round " + (string) item.Element("roundid"),
                            Date = (string) item.Element("date")
                            /*GameID = (string) item.Element("gameid"),
                            Team1 = (string) item.Element("team1"),
                            Team2 = (string) item.Element("team2"),
                            Team1Image = (string) item.Element("team1image"),
                            Team2Image = (string) item.Element("team2image"),
                            Date = (string) item.Element("date"),
                            Location = (string) item.Element("location")*/
                       };
            
            Fixtures = query.Distinct().ToList();
            
            TableView.Delegate = new TableDelegate (this);
            TableView.DataSource = new DataSource (this);
            Title = "Rounds";
            
        }
    }
}

Datasource that loads the detail data based on the round (ID) selection from datasource 1:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Data;
using System.IO;

namespace CurrieCup2012
{
    [MonoTouch.Foundation.Register("DetailFixturesTableViewController")]

    public partial class MyTableViewController2 : UITableViewController
    {
        static NSString CellID2 = new NSString ("MyIdentifier2");
        List<DetailFixtures> DetailFixtures;
        
        public string round{ get; set; }

        // Constructor invoked from the NIB loader
        public MyTableViewController2 (IntPtr p) : base (p)
        {
            
        }
        
        
        // The data source for our TableView
        class DataSource : UITableViewDataSource
        {
            
            MyTableViewController2 tvc;
            
            public DataSource (MyTableViewController2 tableViewController)
            {
                
                this.tvc = tableViewController;
            }
            
            public override int RowsInSection (UITableView tableView, int section)
            {
                return tvc.DetailFixtures.Count;
            }

            public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
            {
                Dictionary<int,FixturesCell> _cellControllers = new Dictionary<int, FixturesCell>();
                var cell2 = tableView.DequeueReusableCell (CellID2);
                FixturesCell fixtureCell = null;
                DetailFixtures detailfixtures = tvc.DetailFixtures.ElementAt(indexPath.Row);
                
                if (cell2 == null)
                {
                    //cell2 = new UITableViewCell (UITableViewCellStyle.Default, CellID2);
                    fixtureCell = new FixturesCell();
                    cell2 = fixtureCell.Cell;
                    cell2.Tag = Environment.TickCount;
                    _cellControllers[cell2.Tag] = fixtureCell;
                }
                else
                {
                    fixtureCell = _cellControllers[cell2.Tag];
                }
            
                // Customize the cell here...
                
                fixtureCell.Team1 = detailfixtures.Team1;
                fixtureCell.Team2 = detailfixtures.Team2;
                fixtureCell.Location = detailfixtures.Location;
                fixtureCell.Date = detailfixtures.Date;
                
                if(!string.IsNullOrEmpty(detailfixtures.Team1Image))
                {
                    if(File.Exists("Images/"+detailfixtures.Team1Image))
                    {
                        fixtureCell.Team1Image = UIImage.FromFile("Images/"+detailfixtures.Team1Image); 
                    }
                }
                
                if(!string.IsNullOrEmpty(detailfixtures.Team2Image))
                {
                    if(File.Exists("Images/"+detailfixtures.Team2Image))
                    {
                        fixtureCell.Team2Image = UIImage.FromFile("Images/"+detailfixtures.Team2Image); 
                    }
                }
            
                /*DetailFixtures detailfixtures = tvc.DetailFixtures.ElementAt(indexPath.Row);
                cell2.TextLabel.Text = detailfixtures.Team1;
                
                //cell.Accessory = UITableViewCellAccessory.DetailDisclosureButton;*/
                
                return cell2;
            }
        }
    
        // This class receives notifications that happen on the UITableView
        class TableDelegate : UITableViewDelegate
        {
            MyTableViewController2 tvc;

            public TableDelegate (MyTableViewController2 tableViewController)
            {
                this.tvc = tableViewController;
            }
            
            
            
            public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
            {
                /*if (detailsViewController == null)
                detailsViewController = new DetailFixturesViewer();
                
                DetailFixtures detailFoxtures = tvc.DetailFixtures.ElementAt(indexPath.Row);
                detailsViewController.CurrentFixtures = fixtures;
                //Console.WriteLine(indexPath.Row.ToString());
                //Console.WriteLine(newsArticle.Headline.ToString());
                //Console.WriteLine(newsArticle.Link.ToString());
                tvc.NavigationController.PushViewController(detailsViewController, true);
                tvc.NavigationController.ViewWillAppear(true);*/
            }
        }

        
        public override void ViewDidLoad ()
        {
            //SelectedRound selround = new SelectedRound();
            
            string selectedRound = SelectedRound.RoundID.Replace("Round ", "");
            Console.WriteLine("read selected Round viewdidload table class: " + selectedRound);
            
            base.ViewDidLoad ();
            
            XDocument rss =
            XDocument.Load("http://curriecup.dutch-vegas.com/XML/fixtures.xml");
            
            var query = from item in rss.Descendants("Game") where (string) item.Element("roundid") == selectedRound
                select new DetailFixtures 
                       {
                            //RoundID = "Round " + (string) item.Element("roundid")
                            GameID = (string) item.Element("gameid"),
                            Team1 = (string) item.Element("team1"),
                            Team2 = (string) item.Element("team2"),
                            Team1Image = (string) item.Element("team1image"),
                            Team2Image = (string) item.Element("team2image"),
                            Date = (string) item.Element("date"),
                            Location = (string) item.Element("location")
                       };
            //Console.WriteLine("test");
            DetailFixtures = query.Distinct().ToList();
            TableView.Delegate = new TableDelegate (this);
            TableView.DataSource = new DataSource (this);
            //Title = "Fixtures";
            Console.WriteLine("Reload");
        }
    }
}

I have tried calling the ReloadData() method on the table but to no avail. I am new new to mono touch.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:28:58+00:00Added an answer on June 5, 2026 at 2:28 pm

    The simplest thing to try is to create a new instance of View2 every time, instead of trying to re-use an existing instance.

    There is nothing wrong with re-using View2, it just would require some more debugging to find out exactly where the problem is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net web service project. This project contains a few classes declared
I have a hobby project that is written in C# using MonoDevelop. I've been
I have a mono android project. I can use monodevelop to build the apk
I have two apps in the app store, both through MonoTouch but after upgrading
I have a project set up in MonoDevelop, it compiles and runs fine for
I have successfully developed a small iPhone+Monotouch (latest version) application with Monodevelop 2.8, which
Is there a way to tell a MonoDevelop project to exclude from source control
I'm trying to get intellisense working in MonoDevelop when writing an ObjC binding project.
I'm using monodevelop on my mac to develop for iPhone. I was wondering if
I'm trying to run MonoDevelop on apple. I have instaled all the necessary SDK

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.