MonoTouch 是 5.2.12。 iOS 是 v5.1.1(模拟器)
似乎我在这里遗漏了一 block 重要的拼图。
我正在子类化 DialogViewController
并将其设置为我的 UINavigationController 中的唯一 Controller 。
在子类 DialogViewController
的 ViewWillAppear
中,我尝试设置左右栏按钮项:
this.NavigationController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, this.HandleDoneButtonTouched );
他们都没有出现。但是会显示标题。如果我调试,我可以看到项目设置正确。
我还尝试在导航 Controller 上使用 SetItems()
:也没有效果。
导航 Controller 以模态方式呈现在页面表中。
最佳答案
导航项通常不会通过导航 Controller 更新。相反,它们通过 View Controller 上的 NavigationItem 属性进行更新:
this.NavigationItem.SetRightBarButtonItem(
new UIBarButtonItem(UIImage.FromFile("some_image.png")
, UIBarButtonItemStyle.Plain
, (sender,args) => {
// button was clicked
})
, true);
关于c# - LeftBarButtonItem 和 RightBarButtonItem 未显示在 MonoTouch.Dialog DialogViewController 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11667554/