添加的UITabBarController时出错 [英] Error when adding UITabBarController

查看:218
本文介绍了添加的UITabBarController时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的的MonoTouch C#写一个iPhone应用程序有多个不同的屏幕。为了简单起见,我将说明导致这我有问题的控制器只有几个画面。

I'm using Monotouch C# to write an iPhone App with a number of different screens. To keep things simple I will describe only a few screens that lead to the controller which I am having issues with.

我遇到的问题是,我收到此错误信息当我创建从的UITabBarController 继承的类:

The problem I am having is that I receive this error message when I create a class which inherits from UITabBarController:

预计应用程序窗口在有根视图控制器应用程序启动的

Application windows are expected to have a root view controller at the end of application launch

在我AppDelegate类初始化我一个UIViewController和一个UINavigationController。我设置了一个UIWindow对象在我的RootViewController的使用导航控制器是这样的:

In my AppDelegate class I initialise a UIViewController and a UINavigationController. I set my RootViewController on the UIWindow object to use the navigation controller like this:

var splashController = new SplashController(); // UIViewController
_navigationController = new UINavigationController(splashController);

...

_window = new UIWindow(UIScreen.MainScreen.Bounds);
_window.RootViewController = _navigationController;
_window.MakeKeyAndVisible();



到现在为止,我还没有一个问题与运行我的应用程序。不过,我创建了一个新的类从继承的UITabBarController,我得到上述错误消息。我可以将代码发布到它如果需要的话,但我也试着运行与我从继承的UITabBarController,我仍然收到同样的错误消息的空类的应用程序。

Up until now I haven't had an issue with running my applications. However I created a new class which inherits from UITabBarController and I get an error message described above. I can post the code to it if needs be but I've also tried running my application with an empty class which inherits from UITabBarController and I still receive the same error message.

即使类从来没有得到过注释掉或删除PushViewController呼叫我仍然无法运行该应用程序调用我的代码。

Even if the class never gets called in my code through commenting out or deleting the PushViewController call I still can't run the application.

标签栏控制器调用最终会是这样的:

The call to the tab bar controller will eventually look like this:

SplashController (UIViewController) > push > HomeController (UIViewController) > push > MenuController (DialogViewController) > push > StatsController (UITabBarController)



我猜有一些额外的东西,我很想念这里,但谷歌搜索和搜索后围绕我无法找到一个答案,我的问题。感谢您的帮助。

I'm guessing there's something extra that I am missing here but after Googling and searching around I couldn't find an answer to my problem. Thanks for any help

推荐答案

如果您正在使用的UITabBarController它应该是这个样子:

If you are using a UITabBarController it should look something like this:

window = new UIWindow (UIScreen.MainScreen.Bounds);

            var viewController1 = new FirstViewController ();
            var viewController2 = new SecondViewController ();

            tabBarController = new UITabBarController ();
            tabBarController.ViewControllers = new UIViewController [] {
                viewController1,
                viewController2,
            };

            window.RootViewController = tabBarController;
            window.MakeKeyAndVisible ();



的UITabBarController应该是RootViewController的。

The UITabBarController should be the RootViewController.

这篇关于添加的UITabBarController时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆