c# - LeftBarButtonItem 和 RightBarButtonItem 未显示在 MonoTouch.Dialog DialogViewController 中

标签 c# xamarin.ios monotouch.dialog

MonoTouch 是 5.2.12。 iOS 是 v5.1.1(模拟器)

似乎我在这里遗漏了一 block 重要的拼图。 我正在子类化 DialogViewController 并将其设置为我的 UINavigationController 中的唯一 Controller 。 在子类 DialogViewControllerViewWillAppear 中,我尝试设置左右栏按钮项:

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);

http://docs.xamarin.com/ios/recipes/Content_Controls/Navigation_Controller/Add_a_Nav_Bar_Right_Button

关于c# - LeftBarButtonItem 和 RightBarButtonItem 未显示在 MonoTouch.Dialog DialogViewController 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11667554/

相关文章:

c# - 从 coldfusion 调用 .net 对象的方法

c# - 编码时打包如何工作?

c# - ASP.Net应用程序部署过程

multithreading - InvokeOnMainThread()不一定要在主线程上调用-错误或功能?

c# - UIControllerView 无法从委托(delegate)函数更新

ios - MonoTouch.Dialog UITableView 没有边距

c# - 我有一个返回字符串的方法,但变量的类型为可为空 bool 值

xamarin - 处理 Xamarin PCL 项目中的文件

c# - 如何将数据传递给 MonoTouch.Dialog 的委托(delegate)?

C# Xamarin/Monotouch.Dialog - EntryElement 不显示输入的字符