UISplitViewController with multiple detail ViewControllers

PoojaGaonkarPoojaGaonkar INMember ✭✭

Hello,

I am trying to implement a UISplitViewController on iPad which has a Master ViewController with a UITableView displaying a menu. I also have an Initial Detail ViewController assigned.

What I want to achieve is that when a row in the Master ViewController menu is clicked, the initial detailViewController should be replaced by another one. Similarly for all other rows in the Master menu.

I have tried something like so:-

public partial class TabSplitViewController : UISplitViewController
    {
        private HomeViewController homeViewController;
        private TabNavViewController navMenuController;

        public TabSplitViewController (IntPtr handle) : base (handle)
        {
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            navMenuController = this.Storyboard.InstantiateViewController("TabNav_VC") as TabNavViewController;
            homeViewController = this.Storyboard.InstantiateViewController("Home_VC") as HomeViewController;

            UpdateViews(navMenuController, homeViewController);
        }

        public void UpdateViews(UIViewController master, UIViewController detail)
        {
            try
            {
                ViewControllers = new UIViewController[] { master, detail };
            }
            catch(Exception ex)
            {

            }
        }

And on Master ViewController (i.e TabNavViewController) row click :-

   var iPadMainController = mViewController.Storyboard.InstantiateViewController("TabSplit_VC") as TabSplitViewController;
  iPadMainController.UpdateViews(iPadMainController .ViewControllers[0], newdetailController);

But doing the above, does change the ViewControllers array elements to the ViewController at the 0th position i.e the master menu itself and the ViewController at the 1st position to the newDetailController, but the UI does not change and the initial ViewController is still displayed.

How can I fix this?

Sign In or Register to comment.