【发布时间】:2014-05-30 13:48:34
【问题描述】:
我正在尝试更改通过 Storyboard 创建的 UILabel 的文本。我有两个 ViewController,FirstViewController 和 SecondViewController。我关闭了 SecondViewController,调用了 SecondViewController 中的方法,在 FirstViewController 中调用了委托方法,但 UILabel 为 nil。 知道为什么吗?
第二视图控制器
-(void)back {
[self.navigationController popToRootViewControllerAnimated:YES];
[self.delegate points:@"10"];
}
FirstViewController
-(void)points:(NSString *)point {
labelPoints.text = [NSString stringWithFormat:@"Points: %@", point];
}
【问题讨论】:
-
检查 labelPoints 是否为零?
-
我就是这么说的。它是零。但为什么呢?
-
你链接你的 IBOutlet 了吗?
-
是的,它是链接的。当我的 viewDidLoad 方法中有断点时,'labelPoints' 不是 nil
-
可能是因为你没有显示在屏幕上?
标签: objective-c uilabel