mono touch中NavigationController构造导航栏和工具栏

有不明白的地方欢迎入群  347636249  探讨
public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			//导航栏
			this.NavigationItem.SetRightBarButtonItem (
				new UIBarButtonItem (UIBarButtonSystemItem.Add, (sender,args) => {
				//Alert (navItems.Count.ToString ());
				navItems [2].Items.Add (new NavItem ("Basic Vici CoolStorage", "", typeof(ViciCoolStorage.BasicOperations)));
				base.TableView.ReloadData(); //需要添加这一项
			}), true);

			//工具栏
			this.NavigationController.ToolbarHidden = false; //默认是隐藏的
			this.SetToolbarItems (new UIBarButtonItem[] {
				new UIBarButtonItem(UIBarButtonSystemItem.Refresh, (s,e) => {
					Console.WriteLine("Refresh clicked");
				}),
				new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace) { Width = 50 }
				, new UIBarButtonItem(UIBarButtonSystemItem.Pause, (s,e) => {
					Console.WriteLine ("Pause clicked");
				})
			}, false);
		}

注意,工具栏默认是隐藏的,所以需要用代码让其显示;

this.NavigationController.ToolbarHidden = false;

具体设计可看:http://docs.xamarin.com/recipes/ios/content_controls/navigation_controller/

mono touch中NavigationController构造导航栏和工具栏_第1张图片

你可能感兴趣的:(mono touch中NavigationController构造导航栏和工具栏)