Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DialogViewController breaks UINavigationController path

I encountered a problem when pushing a DialogViewController to my apps global UINavigationController, that it would lose the back buttons.

I was able to boil it down to this simple example:

var nav = new UINavigationController();
window.RootViewController = nav;

nav.PushViewController(new UIViewController() { Title = "#1"}, true);
nav.PushViewController(new DialogViewController(new RootElement("#2")), true);
nav.PushViewController(new UIViewController() { Title = "#3"}, true);

You can get from #3 to #2, but not from #2 to #1.

Am I doing something wrong with the DialogViewController? I though they could work as a drop-in replacement for UIViewController.

like image 535
Timm Avatar asked Feb 20 '12 17:02

Timm


1 Answers

Simply use:

nav.PushViewController(new DialogViewController(new RootElement("#2"), true), true);

i.e. extra true for the DialogViewControler constructor.

like image 196
poupou Avatar answered Sep 22 '22 07:09

poupou