1

我有一个包含嵌入式表和标签的视图。调用 Web 服务,标签应显示调用的值。该调用返回适当的字符串,但标签拒绝设置任何内容。即使是硬编码的字符串也不起作用。

这是我在标题中声明的内容:

@property (retain, nonatomic) IBOutlet UILabel *textLabel;

这是我在 viewDidLoad 中的实现...(已经合成 textLabel):

textLabel.text = @"For the love of God PLEASE display!!";
//also tried with self.textLabel.text.... but that shouldn't matter... right?
//also tried the following line to no avail:
//[self.textLabel setText:@"This didnt work either"];

我曾尝试将标签放在与桌子相同的容器中,但这也不起作用。标签显示的唯一情况是我在界面生成器中设置了值。

我觉得这可能是由于一些与在我的 UIview 中嵌入表格视图相关的 UI 绘画/刷新问题。有没有人有任何想法?

4

4 回答 4

0

Why dont you try this and check

 textLabel.text = [NSString stringWithFormat:@"%@", yourStringFromWebCall]; 

or

 textLabel.text = [NSString stringWithString:@"%@", yourStringFromWebCall];

Also check once whether you have connected the IBOutlet in the nib file to the label... May be that is the issue here

于 2012-04-27T04:32:52.737 回答
0

So I found a solution... I knew the table cells were getting filled in with the proper values just fine, so I set the

[textLabel setText:webServiceText]

just before the return for the following method:

- (UITableViewCell *)tableView cellForRowAtIndexPath:(NSIndexPath *) indexPath

And voila! It works now! I still find it incredibly strange that it wouldn't work before with all the other places I tried, so if anyone has explanations, I'd love to hear them!

于 2012-04-27T16:13:30.643 回答
0

您的 IBOutlet 设置不正确。尝试从 xib 中删除您的标签并添加一个新标签。

再次连接您的 IBOutlet。

@property (retain, nonatomic) IBOutlet UILabel *textLabel;
于 2012-04-27T04:45:02.260 回答
0

您是否在调用 Web 服务以更改标签后重新加载表?

于 2012-04-27T04:09:33.413 回答