UIWindowのRootViewControllerプロパティを設定することは、NavigationControllerを使用する適切な方法です。
MyViewCtrl ctrl1 = new MyViewCtrl ("One");
_nav = new UINavigationController (ctrl1);
window.RootViewController = _nav;
また、コントローラーのShouldAutorotateToInterfaceOrientationメソッドをオーバーライドすることを忘れないでください。これが完全なサンプルです
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
UIWindow window;
UINavigationController _nav;
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
MyViewCtrl ctrl1 = new MyViewCtrl ("One");
_nav = new UINavigationController (ctrl1);
window.RootViewController = _nav;
window.MakeKeyAndVisible ();
return true;
}
}
public class MyViewCtrl : UIViewController
{
public MyViewCtrl (string title)
{
this.Title = title;
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
this.View.BackgroundColor = UIColor.White;
if (this.Title.Equals ("One"))
{
UIBarButtonItem testButton =
new UIBarButtonItem ("Two", UIBarButtonItemStyle.Bordered,
(object sender, EventArgs e) => {
this.NavigationController.PushViewController (
new MyViewCtrl ("Two"), true);
} );
this.NavigationItem.RightBarButtonItem = testButton;
}
}
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
return true;
}
}