在viewcontroller加载后设置值

时间:2012-08-01 00:08:54

标签: iphone ios delegates nsstring protocols

我想知道如何或是否有可能重新加载一个整体视图,因为我想要在UIView上显示我想要显示的NSString但是因为数据来自在另一个类中初始化的协议/委托不是将成为子视图的视图..我无法在文本标签中显示此NSString,因为ViewController已经在数据被喷射到委托/协议之前已经加载..这是我的代码简单如。 ...我需要弄清楚如何在加载视图之前重新加载视图或将值传递给视图。

//These methods are declared inside ConnectionResponses.h as delegates to pass informatin to this view from ConnectioneResponses.
- (void)sendSeriesSearchArray:(NSArray *)array seriesToolBar:(NSString *)seriesToolBarString
{
    int arrayCount = [array count];
    NSLog(@"%i", arrayCount);


    manufactureToolBarLabel.text = seriesToolBarString;

}

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

在ViewController.m中,在init:

时添加代码
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doSomething:) name:@"ValueChanged" object:nil];
在某个属性发生更改时,在您的委托/协议中添加代码

[[NSNotificationCenter defaultCenter] postNotificationName:@"ValueChanged" object:nil];

然后在doSomething方法中:您可以根据需要更改UI。

相关问题