简而言之,我有一个SplitViewController作为RootController。 在构造函数中,我添加了主控制器和明细控制器。 详细信息控制器包装在导航控制器中。
{
_masterViewController = new MenuViewController();
_inventories = new InventoriesViewController();
_detailNavigationController = new UINavigationController(_inventories);
ViewControllers = new UIViewController[] {
_masterViewController,
_detailNavigationController
};
如何在详细信息导航栏上显示菜单(显示主菜单)后退按钮?
我们不使用情节提要
答案 0 :(得分:0)
在ViewDidLoad()方法中添加以下代码
UIButton backButton = new UIButton();
backButton.Frame = new CGRect(0,0,20,20);
backButton.SetTitle("Back", UIControlState.Normal);
backButton.SetTitleColor(UIColor.Gray, UIControlState.Normal);
backButton.SetImage(new UIImage("back"), UIControlState.Normal);
//backButton.SetImage(new UIImage("001.jpg"), UIControlState.Normal);
backButton.TouchUpInside += (sender, e) =>
{
NavigationController.PopViewController(true);
};
UIBarButtonItem backItem = new UIBarButtonItem(backButton);
NavigationItem.LeftBarButtonItem = backItem;
答案 1 :(得分:0)
一段时间后,我在UISplitViewController上找到了属性
DisplayModeButtonItem
因此,在创建主控制器和明细控制器之后(详细控制器包装在UINavigationController中),我将DisplayModeButtonItem添加到了明细控制器的NavigationBar LeftItem中。它给了我想要的外观和行为
{
_masterViewController = new MenuViewController();
_inventories = new InventoriesViewController();
_inventoriesNavigation = new UINavigationController(_inventories);
_inventories.NavigationItem.LeftBarButtonItem = DisplayModeButtonItem;
ViewControllers = new UIViewController[] {
_masterViewController,
_inventoriesNavigation
};
}