MonoTouch:UITabBarController 抛出“已加载笔尖,但未设置视图出口”

发布于 2024-12-21 02:26:29 字数 638 浏览 5 评论 0原文

我一直在网上搜索,但找不到解决方案。

我创建了一个新的 MonoTouch iPhone 解决方案。

我创建一个名为 myTestView 的新视图。

我添加了一个 UITabBarController

我保存并退出 Interface Builder。

AppDelegate.cs 中,我有这段代码...

public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
    window = new UIWindow (UIScreen.MainScreen.Bounds);
    viewController = new myTestView ();
    window.RootViewController = viewController;
    window.MakeKeyAndVisible ();
    return true;
}

我运行应用程序并收到此错误:加载了“myTestView”笔尖,但未设置视图插座

Emmm 我可以不知道我错过了什么设置。有什么想法吗?

I've been searching the web, but can't find a solution.

I create a new MonoTouch iPhone solution.

I create a new view called myTestView.

I add a UITabBarController.

I save and exit Interface Builder.

In AppDelegate.cs I have this code...

public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
    window = new UIWindow (UIScreen.MainScreen.Bounds);
    viewController = new myTestView ();
    window.RootViewController = viewController;
    window.MakeKeyAndVisible ();
    return true;
}

I run the app and get this error: loaded the "myTestView" nib but the view outlet was not set

Emmm I can't figure out what setting I miss. Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萌酱 2024-12-28 02:26:29

每个 XIB 文件都有一个名为“view”的默认出口。

它必须连接到 ViewController 中您想要的根 View,否则您会收到消息:“未设置视图出口”。

举例来说,假设我想要一个新的 UITableViewController:

  • File->New->File->iPhone View Controller
  • 将我的控制器更改为从 cs 文件中的 UITableViewController 继承
  • 在 XCode 中打开 XIB 文件
  • 删除根 UIView
  • 添加 UITableView到我的文件
  • 右键单击文件的所有者并将“视图”出口映射到带有愚蠢的蓝线的新 UITableView

这应该可以解决您的错误。

There is a default outlet for every XIB file called "view".

It must be hooked up to the root View you want in your ViewController, otherwise you get the message: "view outlet was not set".

So for example, let's say I want a new UITableViewController:

  • File->New->File->iPhone View Controller
  • Change my controller to inherit from UITableViewController in cs file
  • Open the XIB file in XCode
  • Delete the root UIView
  • Add a UITableView to my file
  • Right click on File's Owner and map the "view" outlet to the new UITableView with the stupid blue line thingy

This should resolve your error.

温柔嚣张 2024-12-28 02:26:29

您是否将新视图创建为带有控制器的视图?这是唯一对我有用的视图类型。

您还应该检查一些其他事项:

1)确保您的构造函数在主视图文件中存在且正确:

    //loads the myTestView.xib file and connects it to this object
    public myTestView () : base ("myTestView ", null)
    {
    }

2)确保设计器文件已正确创建并具有正确的信息:

[Register ("myTestView")]
partial class myTestView
{

Did you create your new view as a View with Controller? This is the only view type that has worked for me.

You should also check a couple of additional things:

1) Ensure your constructor is present and correct in your main view file:

    //loads the myTestView.xib file and connects it to this object
    public myTestView () : base ("myTestView ", null)
    {
    }

2) Ensure the designer file was created correctly and has the correct information:

[Register ("myTestView")]
partial class myTestView
{
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文