Xcode 4.3:IBOutlet的重复连接 [英] Xcode 4.3: duplicated connections of an IBOutlet

查看:187
本文介绍了Xcode 4.3:IBOutlet的重复连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习斯坦福CS193p课程与Xcode 4.3.3。我认为下面的截图是很自我解释。但我会用字来描述问题。

I am learning Stanford CS193p course with Xcode 4.3.3. I think the screenshot below is pretty much self-explaining. But i will describe the problem with words anyway.

我控制 - 将UILabel从故事板拖放到相应的实现文件,以创建IBOutlet @property。然后,当单击编辑器左侧的填充圆时,显示两个连接,其中显示行号。我不知道如何删除它。

I control-drag a UILabel from storyboard to corresponding implementation file to make the IBOutlet @property. Then I see two connections displayed when clicking the filled circle in the left side of the editor where shows line numbers. I don't know how to delete it.

此外,我在UIlabel的storyboard的连接检查器中只看到一个连接。

Moreover, I see only ONE connection in storyboard's connections inspector of the UIlabel.

更奇怪的是,当我尝试将UILabel的文本设置为公共预设的setter时,它无法更新标签的文本:

More weird, when I try to set the UILabel's text inside the setter of a public preperty, it fails to update the label's text:

 -(void) setQuestion:(NSString *)question
 {
     _question = question;
     self.questionLabel.text = question;
     NSLog(@"The quesion is %@",question);
     NSLog(@"The quesion label text is %@",self.questionLabel.text);
 }



我使用两个NSLog来调试并获得以下内容。它显示NSString *问题是@你想要你的标签说什么?,但self.questionLabel.text为null。值分配失败。我怀疑这与上面提到的重复连接有关。

I use two NSLog to debug and get the following. It shows the NSString *question is @"What do you want your label to say?", yet the self.questionLabel.text is null. The value assign fails. I suspect this relate to the duplicated connections thing mentioned above.


2012-07-29 04:03:53.817厨房水槽[18628:f803 ]问题是什么
你想要你的标签说?

2012-07-29 04:03:53.820厨房
水槽[18628:f803] quesion标签文本是(null)

2012-07-29 04:03:53.817 Kitchen Sink[18628:f803] The quesion is What do you want your label to say?
2012-07-29 04:03:53.820 Kitchen Sink[18628:f803] The quesion label text is (null)

以下是显示重复连接的屏幕截图。我可能缺少明显的东西,请帮助。

The following is the screenshot showing the duplicated connections. I am probably missing something obvious, please help.

推荐答案

我会把这个跟Xcode storyboard wonkiness。

I would stalk this up to Xcode storyboard wonkiness.

首先,尝试清除项目并重新构建。

First, try a clean of the project and a re-build.

,通过执行以下操作,手动定义@property而不从AskerViewController视图拖到AskerViewController实现(.m)文件。

Should you still have that problem, manually define the @property without dragging from the AskerViewController view to the AskerViewController implementation (.m) file by doing the following.

剪切IBOutlet @property行AskerViewController的实现(.m)文件部分。单击故事板中的标签。断开标签到AskerViewController的任何绑定。清洁项目。然后,将其粘贴回属性,并将控件从标签拖动到您的故事板文件中的AskerViewController视图底部的视图控制器orb。

Cut that IBOutlet @property line in the interface section of the implementation (.m) file for AskerViewController. Click the label in storyboard. Disconnect any binding that label to the AskerViewController. Clean the project. Then, paste back in the property, and control-drag from the label to the view controller orb at the bottom of the AskerViewController view in your storyboard file.

这篇关于Xcode 4.3:IBOutlet的重复连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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