C#Monotouch / Xamarin.iOS - 不支持推送导航控制器

时间:2014-01-28 19:02:14

标签: c# uinavigationcontroller xamarin.ios xamarin pushviewcontroller

我有一个为iOS7编写的应用程序....

我的AppDelegate中有以下代码

[Register ("AppDelegate")]
        public partial class AppDelegate : UIApplicationDelegate
        {
            // class-level declarations
            UIWindow window;
            UINavigationController navigationController;
            HomeViewController_iPhone homeViewController;

        public override bool FinishedLaunching (UIApplication app, NSDictionary options)
        {
            window = new UIWindow (UIScreen.MainScreen.Bounds);

            homeViewController = new HomeViewController_iPhone ();
            navigationController = new UINavigationController (homeViewController);
            window.RootViewController = navigationController;
            window.MakeKeyAndVisible ();

            return true;
        }
    }

此行未通过

navigationController = new UINavigationController (homeViewController);

HomeViewController是一个UINavigationController类......

构建我的代码时收到以下错误 抛出了MonoTouch.Foundation.MonoTouchException。 抛出Objective-C异常。名称NSInvalidArgumentException 原因:不支持推送导航控制器。

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

问问自己为什么要在UINavigationController上创建新的UINavigationController

如果您的homeViewControllerUINavigationController,那么只需执行以下操作:

window.RootViewController = new HomeViewController_iPhone ();

或者您的homeViewController不应该是导航控制器?