4

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

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

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

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

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

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

4

1 回答 1

7

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

于 2012-07-26T10:51:53.343 回答