0

我有问题UISplitviewcontroller

当我创建splitviewcontroller(第一次)显示 barbutton 并且它工作正常时,

在 master 中选择表行后,它的 remove detailview1& add detailview2,现在 barbutton 未显示。如果我旋转 iPad barbutton 将显示,

我不知道为什么最初不显示栏按钮。我设置了委托,即使它没有显示栏按钮。

这是我使用的代码:

        UINavigationController navMaster = appDel.SplitView.ViewControllers [0] as UINavigationController;

        if (indexPath.Row == 0) 
        {  
            ViewController1 View1 = new ViewController1 ();
            UINavigationController nav1 = new UINavigationController (View1); 
            appDel.SplitView.WeakDelegate = View1;              
            appDel.SplitView.ViewControllers = new UIViewController[]{ navMaster, nav1 }; 
        }  
        else if (indexPath.Row == 1) 
        {
            ViewController2 View2 = new ViewController2 ();
            UINavigationController nav2 = new UINavigationController (View2); 
            appDel.SplitView.WeakDelegate = View2;              
            appDel.SplitView.ViewControllers = new UIViewController[]{ navMaster, nav2 }; 
        }

detailviewcontroller1这是在和中设置的委托detailviewcontroller2

[Export("splitViewController:willHideViewController:withBarButtonItem:forPopoverController:")]
        public void WillHideViewController (UISplitViewController splitController, UIViewController viewController, UIBarButtonItem barButtonItem, UIPopoverController popoverController)
        {
            barButtonItem.Title = "Inputs";
            NavigationItem.SetLeftBarButtonItem (barButtonItem, true);
            masterPopoverController = popoverController;
        }

    [Export("splitViewController:willShowViewController:invalidatingBarButtonItem:")]
    public void WillShowViewController (UISplitViewController svc, UIViewController vc, UIBarButtonItem button)
    {
        NavigationItem.SetLeftBarButtonItem (null, true);
        masterPopoverController = null;
    }

谁能帮我 ?

4

1 回答 1

2

WillHideViewController不会在您的示例中调用,因为您WeakDelegate在显示新控制器之前设置了属性。如果您切换这两个语句的顺序,您将遇到类似的问题,并且WillShowViewController不会被调用。

有没有办法可以处理来自单个类的拆分视图委托?通常我在一个子类中处理这个委托UISplitViewController并且只设置WeakDelegate一次。

于 2013-08-27T12:21:27.020 回答