모달로 표시된 UINavigationController의 맨 아래에 간단한 UIToolbar를 넣으려고합니다. 이 샘플에는 '취소'와 '무언가'의 두 가지 버튼이 있어야합니다.UIToolbar가있는 모달 UINavigationController - 툴바가 비어 있습니다.
...
UINavigationController modalNavigationController = new UINavigationController(someViewController);
modalNavigationController.NavigationBar.BarStyle = UIBarStyle.Black;
modalNavigationController.Toolbar.BarStyle = UIBarStyle.Black;
modalNavigationController.ToolbarHidden = false;
UIBarButtonItem cancelButton = new UIBarButtonItem("cancel", UIBarButtonItemStyle.Plain, delegate {
modalNavigationController.DismissModalViewControllerAnimated(true);
});
UIBarButtonItem flexSpace = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null);
UIBarButtonItem someButton = new UIBarButtonItem("something", UIBarButtonItemStyle.Plain, delegate {
Console.WriteLine("here we are!");
});
modalNavigationController.ToolbarItems = new UIBarButtonItem[] { cancelButton, flexSpace, someButton };
parentController.PresentModalViewController(modalNavigationController, true);
...
도구 모음이 나타나고 검은 색 스타일로 지정되어 있지만 항목이 하나도 포함되어 있지 않습니다. 숨김, 효과 없음으로 설정하기 전에 항목을 할당 해 보았습니다. Toolbar.Items 및 Toolbar.Hidden뿐만 아니라 SetToolbarItems() 및 SetToolbarHidden() 대신 행운을 사용하여 시도했다.
여기에 무엇이 잘못 되었을지에 대한 힌트가 있습니까? 감사합니다
편집 : 그물에
대부분의 샘플이 자신의 UIToolbar를 만들고 하위 뷰로 추가. 그건 UINavigationController가 필요하지 않습니다. AFAICT, 그것은 하나의 내장되어 있습니다.
+1 대답 자신을 게시 :) –