如何在iPhone SDK中使用标签栏控制器设置视图出口 [英] How to set view outlet using tab bar controller in iPhone SDK

查看:45
本文介绍了如何在iPhone SDK中使用标签栏控制器设置视图出口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Xcode创建了一个简单的标签栏应用程序.

I created a simple tab bar application in Xcode.

默认选项卡栏有2个选项卡栏项.我添加了第三个选项卡栏项,并将其视图控制器属性设置为我创建并随后保存的名为ThirdView.xib的视图.

The default tab bar has 2 tab bar items. I add a third tab bar item and set its view controller attribute to a view i had created and subsequently saved called ThirdView.xib.

当我尝试运行时,前两个默认选项卡可以正常工作.我添加的第三个抛出此错误:

When I try to run, the first two default tabs work fine. The third one I added throws this error:

    *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', 
reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "ThirdView" nib but 
the view outlet was not set.'

我很抱歉,因为我是个巨大的iPhone-SDK n00b,但是单击和拖动以及按住Control键并拖动的方式都不允许我在创建的第三个视图上设置视图出口.

I apologize as I'm a huge iPhone-SDK n00b, but no manner of clicking and dragging and control-click dragging is allowing me to set the view outlet on the third view I had created.

推荐答案

10分钟前,我遇到了类似的问题,它是未保存的xib文件:).由于某些原因,XCode一次运行时不要求保存xib文件.

I had similar problem 10 mins ago, it was unsaved xib file :). For some reasons XCode doesn't ask to save xib files when one hit run.

但是,如果不是这种情况,我将仔细检查该视图是否确实在xib文件中连接了.

But if that isn't the case, I would double check if the view is indeed connected in the xib file.

为此,将ThirdView.xib作为纯文本文件打开(右键单击>另存为">纯文本文件")并搜索文本:> view<".如果该视图已连接,则应该找到类似于以下代码的内容:

To do so open ThirdView.xib as plain text file (right click > open as > plain text file) and search for text: ">view<". If the view is connected you should find something similar to the code below:

<object class="IBConnectionRecord">
    <object class="IBCocoaTouchOutletConnection" key="connection">
        <string key="label">view</string>
        <reference key="source" ref="372490531"/>
        <reference key="destination" ref="191373211"/>
    </object>
    <int key="connectionID">15</int>
</object>

如果找不到它,则表明该问题是由Interface Builder中的错误引起的.然后,您可以尝试手动添加连接.让我知道是否是这种情况.

If you can't find it this could mean that the problem is caused by a bug in Interface Builder. Then you can try to add the connection by hand. Let me know if that is the case.

这篇关于如何在iPhone SDK中使用标签栏控制器设置视图出口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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