【问题标题】:setting values after viewcontroller has loaded在视图控制器加载后设置值
【发布时间】:2012-08-01 00:08:53
【问题描述】:

我想知道如何或是否可以重新加载整个视图,因为我正在接收一个我想在 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;

}

任何帮助将不胜感激

【问题讨论】:

    标签: iphone ios delegates nsstring protocols


    【解决方案1】:

    在你的 ViewController.m 中,在初始化时添加代码:

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doSomething:) name:@"ValueChanged" object:nil];
    

    当某些属性发生变化时,在您的委托/协议中添加代码:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多