【发布时间】:2013-07-18 11:58:07
【问题描述】:
我只想更改标签的文本。在那里,我有一个指向 Xib 接口的 ViewController,在该接口中创建标签并链接到 ViewController。我只是创建了这个视图控制器的一个实例,想要更改标签的文本:
NewFormScoreViewController * newPoints=[[NewFormScoreViewController alloc] init];
[newPoints.TheNewScoreLabel setText:[NSString stringWithFormat:@"%i",newScore]];
[newPoints.view setFrame:CGRectMake(500, 500, newPoints.view.frame.size.width, newPoints.view.frame.size.height)];
[self.view addSubview:newPoints.view];
视图可见,但只显示占位符,而不是新字符串。 [NSString stringWithFormat:@"%i",newScore] 返回了需要的String,但是好像传输不起作用。但为什么?怎么了?
【问题讨论】:
-
您想从 First View Controller 更改 yourLabel 的值(位于 Second View Controller 中)吗?
-
我想从视图中更改标签,其中 viewcontrollersview 作为子视图加载,我还尝试在 NewFormScoreViewController 中添加一个更改标签的方法,数据传输正确,但如果我使用 [label setText:STRING] 并且在有一个返回标签文本的 NSLog 之后它也是(null)
标签: ios objective-c xcode label xib