Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MonoTouch.Dialog: Back item in NavigationBar

I m having a hard time with this issue. My MainWindow.xib, has a NavigationController, the view for which is inherited from another xib.

Now, i push a DialogViewController from the main view, but i cannot see a back button on the second view's navigation bar.

Is there anything specific that i need to set for the DialogViewController when it is being pushed from a UIViewController.

Thanks and Regards Abhishek

like image 742
Abhishek Sharma Avatar asked Dec 19 '11 11:12

Abhishek Sharma


People also ask

What is MonoTouch dialog?

MonoTouch.Dialog, referred to as MT.D for short, is a rapid UI development toolkit that allows developers to build out application screens and navigation using information, rather than the tedium of creating view controllers, tables, etc. As such, it provides a significant simplification of UI development and code reduction.

How do I use MonoTouch in Visual Studio 2017?

To use it, right-click on the References node of a Xamarin.iOS project in Visual Studio 2017 or Visual Studio for Mac and add a reference to the MonoTouch.Dialog-1 assembly. Then, add using MonoTouch.Dialog statements in your source code as necessary.

How do I add a mydialog to a navigation graph?

Go back to the navigation graph and add a destination. In the popup menu, you can see that it knows about MyDialog. Select that. Select MyDialog from the list as the new destination… and make sure it’s coming in as a “Dialog” and not a “Fragment” Observant readers might notice a little IDE bug in the screenshot above.

What is the behavior of a stringelement in MonoTouch?

This is the behavior for all of the Elements that are part of MonoTouch.Dialog, but it is not required for user-created elements. A StringElement shows a caption on the left side of a table cell and the string value on the right side of the cell.


2 Answers

The constructor for DialogViewController has a parameter called pushing which you should set to true:

new DialogViewController(rootElement, true); // true will show the back button
like image 196
dan gibson Avatar answered Sep 27 '22 20:09

dan gibson


Without seeing your code, I'm not sure exactly what's going wrong here. However, from what I know of UINavigationController, the view controller stack starts empty. When you push the first view controller, it gives the navigation controller a view to display, but it has nothing to go 'back' to, so it does not display a back button. If you push a second view, you may get a back button.

Also, be sure that the Title property is set on your child view controllers if you want the back button to reflect the view you will be going back to.

like image 45
David Merriman Avatar answered Sep 27 '22 21:09

David Merriman