gpt4 book ai didi

Xcode 4.3 : duplicated connections of an IBOutlet

转载 作者:行者123 更新时间:2023-12-02 05:06:01 25 4
gpt4 key购买 nike

我正在使用 Xcode 4.3.3 学习斯坦福 CS193p 类(class)。我认为下面的屏幕截图几乎是不言自明的。但无论如何我都会用文字来描述这个问题。

我将 UILabel 从 Storyboard 控制拖动到相应的实现文件以制作 IBOutlet @property。然后,当单击编辑器左侧显示行号的实心圆圈时,我看到显示了两个连接。我不知道如何删除它。

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

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

 -(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 为空。赋值失败。我怀疑这与上面提到的重复连接有关。

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)



以下是显示重复连接的屏幕截图。我可能遗漏了一些明显的东西,请帮忙。

enter image description here

最佳答案

我会追究到 Xcode Storyboard的怪癖。

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

如果您仍然有这个问题,请手动定义 @property,而无需通过执行以下操作从 AskerViewController View 拖动到 AskerViewController 实现 (.m) 文件。

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

关于Xcode 4.3 : duplicated connections of an IBOutlet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11704316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com