iPhone NavigationControl工具栏项目

时间:2010-05-21 00:08:06

标签: iphone toolbar xamarin.ios navigationcontroller

MonoTouch首选,但Obj-C也可以

我的MainWindow.xib有一个NavigationView和一个View。 View看起来很好并且有效,但是我需要在工具栏中添加按钮,这是NavigationView的一部分。我可以在IB中看到工具栏。

在此视图中,我尝试将按钮添加到工具栏,但它们不会出现。

UIBarButtonItem btnBrowse = new UIBarButtonItem ("Browse", UIBarButtonItemStyle.Bordered, null);
UIBarButtonItem btnOptions = new UIBarButtonItem ("Options", UIBarButtonItemStyle.Bordered, null);
UIBarButtonItem btnBibles = new UIBarButtonItem ("Bibles", UIBarButtonItemStyle.Bordered, null);
UIBarButtonItem btnSpacer = new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace);
void WireUpCommands ()
{
    this.NavigationController.Toolbar.SetItems (new[] { btnOptions, btnSpacer, btnBrowse, btnSpacer, btnBibles }, false); 
}

1 个答案:

答案 0 :(得分:1)

找到它。现在,每个视图都将其自己的工具栏控制为NavigationController的子项。

this.ToolbarItems = new[] { btnOptions, btnSpacer, btnBrowse, btnSpacer, btnBibles };