【问题标题】:Iphone: label text udates value but does not show in viewIphone:标签文本更新值但未显示在视图中
【发布时间】:2009-12-11 14:27:25
【问题描述】:

m working on a part of code where a label text should change value after getting a new value from a singleton class. Seems simple enough, and after testing the value it actually changes aswell, but its not updated in the view. In the view it stays the same as before. Ive 尝试了 -(void)viewDidLoad 和 -(void)viewWillAppear:(BOOL)animated 中的代码,但结果相同.. 有什么想法吗?

这是我的代码:

- (void)viewDidLoad {
//get the new status value
sharedBarCodeValue = [BarcodeValues sharedBarCodeValues];
if([[sharedBarCodeValue storeBarCodeValue] isEqualToString:@"123456"])
{
    [statusText setText:@"This is a new status text"];
}
//for testing, output status text
NSLog(@"status: %@", statusText.text);
[super viewDidLoad];

}

编辑:哦,我应该提到我已经实现了一个导航控制器,当从堆栈中弹出一个 2. 级别视图并返回到根视图时,值应该会改变。

【问题讨论】:

    标签: iphone objective-c text singleton label


    【解决方案1】:

    确保您的 statusText 出口正确连接到您的 IB 对象。

    【讨论】:

    • 是的..它已连接,我尝试输入 statusText.text = @"test";在 viewdidload 中,它会更改视图中的值...所以这不是问题:(
    • 会不会和导航控制器有关?从堆栈中的 2.level 更改为 root 级别时,视图可能不会刷新?
    • 我不确定我是否在关注你。
    • 呵呵.. nvm.. 我什至尝试以编程方式创建新标签,但它们没有显示.. 很奇怪......
    猜你喜欢
    • 2016-11-27
    • 1970-01-01
    • 2012-01-06
    • 2014-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-02
    • 1970-01-01
    相关资源
    最近更新 更多