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

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

问题描述

我正在使用 Xcode 4.3.3 学习斯坦福 CS193p 课程.我认为下面的屏幕截图非常不言自明.但我还是会用文字来描述问题.

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 连接检查器中只看到一个连接.

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

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

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 *question 是 @"What do you want your label to say?",但 self.questionLabel.text 为空.赋值失败.我怀疑这与上面提到的重复连接有关.

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 厨房Sink[18628:f803] 问题标签文本为(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 故事板的怪癖.

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.

在 AskerViewController 的实现 (.m) 文件的接口部分中剪切 IBOutlet @property 行.单击情节提要中的标签.断开该标签与 AskerViewController 的任何绑定.清理项目.然后,粘贴回该属性,并从标签控制拖动到情节提要文件中 AskerViewController 视图底部的视图控制器球体.

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天全站免登陆