【问题标题】:LeftBarButtonItem and RightBarButtonItem not shown in MonoTouch.Dialog DialogViewControllerMonoTouch.Dialog DialogViewController 中未显示 LeftBarButtonItem 和 RightBarButtonItem
【发布时间】:2012-07-26 10:41:46
【问题描述】:

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

似乎我在这里错过了一个重要的难题。 我正在继承DialogViewController 并将其设置为我的 UINavigationController 中的唯一控制器。 在子类DialogViewController 的ViewWillAppear 中,我正在尝试设置左右栏按钮项:

this.NavigationController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, this.HandleDoneButtonTouched );

他们中的任何一个都没有出现。但是会显示标题。如果我调试,我可以看到项目设置正确。

我也尝试在导航控制器上使用SetItems():也没有效果。

导航控制器以模态方式显示在页面表中。

【问题讨论】:

    标签: c# xamarin.ios monotouch.dialog


    【解决方案1】:

    导航项通常不通过导航控制器进行更新。相反,它们通过视图控制器上的 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多