我在新建一个通过IB创建的UIViewController之后,对立面的UILabel进行了编辑,然后显示出来,但是发现UILabel立面的内容根本没有改变。这是为什么?NewViewController *newViewController = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
[newViewController.textLabel setText:@"Just Change Text"];
[self.navigationController pushViewController:newViewController animated:YES];

解决方案 »

  1.   

    给你出一馊主意,先把label背景色涂成特别的颜色,,,看看能不能显示
    如果能显示的话,那就是文字的问题啦
      

  2.   

    延迟加载的问题 在viewController 初始化后里面的view还没有载入
    只有push的时候才会载入view
    newViewController.textLabel 应该是0x0....
      

  3.   

    顶一个,我也常遇到这样的问题。objective-c的规则比较宽松,如果对一个零指针发送消息(即函数调用),是不会产生任何错误的,所以很容易让人产生错觉——代码无错。解决方法就是在view controller的viewDidLoad 方法中对view的数据进行初始化。
      

  4.   

    好象有看过此类问题
    把[newViewController.textLabel setText:@"Just Change Text"];
    放到[self.navigationController pushViewController:newViewController animated:YES];后面。刷新问题的说
      

  5.   

    newViewController.textLabel  此时的textLabel应该为nil,因为通过xib创建的uilabel,需要viewdidload内才真正加载。