无法编译连接iOS5 [英] Can't compile connection iOS5
问题描述
在我正在为iPhone工作的应用程序上,当我要求它给我一个原型表格单元格上的标签出口时,它决定不对我进行编译。之前我已经获得了标签的出口,但我使用的只是标准视图或静态单元而不是原型单元。我认为它可能与标签属于原型单元格并且将被复制的事实有关,因为它们都具有相同的标识符(Cell),但是我可能再次关闭。我不知道如何处理这个,如果我只使用 cell.textLabel.text
那么我的上传按钮直到我点击单元格后才显示。
错误:
无法编译连接:< ; IBCocoaTouchOutletConnection:0x4007cd200< IBProxyObject:0x4007de280> => lblServerName2 => < IBUILabel:0x4009b7d00>>
有没有人对如何设置自定义标签内的文字有任何建议?单元?
作为参考,我上传了我的项目这里。目前这是一团糟,但它目前只是概念类型的证明。一旦我开始工作,我就会经过清理工作。
任何建议都值得赞赏。
<编辑:
此页面有所帮助。在发布此问题后我几乎立刻就找到了它。基本上,我将标签的标签设置为100,然后在cellForRowAtIndexPath方法中使用此代码。
UILabel * lblServerName = (UILabel *)[cell viewWithTag:100];
lblServerName.text = [server getName];
就在那里,我的标签工作正常,我的按钮显示出来。
要更改任意UITableViewCell上标签中的文本,请为标签指定标签,然后在代码中执行以下操作:
UITableViewCell * cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathWithIndex:2]];
if(cell!= nil){
//这假设你在标签上设置标签为
UILabel * label =(UILabel *)[cell viewWithTag:1];
label.text = @新文字;
}
On an app I'm working on for the iPhone, it has decided to not compile on me when I ask it to give me an outlet to a label on a prototype table cell. I've gotten outlets for labels before, but I was using either just a standard view or static cells rather than prototype cells. I'm thinking it probably has to do with the fact that the label belongs to a prototype cell and will be duplicated since they all have the same identifier (Cell), but then again I could be off. I'm not sure what to do with this one, if I use just cell.textLabel.text
then my upload button doesn't show up until after I click on the cell.
The Error:
Couldn't compile connection: <IBCocoaTouchOutletConnection:0x4007cd200 <IBProxyObject: 0x4007de280> => lblServerName2 => <IBUILabel: 0x4009b7d00>>
Does anyone have any suggestions as to how I could go about setting the text on a custom label inside a cell?
For reference, I've uploaded my project here. It's a mess at the moment, but it's currently just a proof on concept kind of thing. I'm going to go through and do clean up once I get it working.
Any suggestions are appreciated.
EDIT:
This page helped out. I found it almost immediately after posting this question. Basically, I set the tag of my label to 100 and then used this code inside of the cellForRowAtIndexPath method.
UILabel *lblServerName = (UILabel*)[cell viewWithTag:100];
lblServerName.text=[server getName];
and there it was, my label working correctly and my button showing up.
To change the text in a label on an arbitrary UITableViewCell, assign a tag to the label, and then in code do something like the following:
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathWithIndex:2]];
if (cell != nil) {
// This assumes that you set the tag to 1 on the label
UILabel *label = (UILabel *)[cell viewWithTag:1];
label.text = @"New Text";
}
这篇关于无法编译连接iOS5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!