【问题标题】:Reload table view when receive notification收到通知时重新加载表格视图
【发布时间】:2013-02-26 08:58:24
【问题描述】:

我有一个基于UITableViewController 的视图控制器,我想在收到更新通知时重新加载表格视图:

    if (self) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateApStatus:) name:@"UpdateApStatus" object:nil];
    }


- (void)updateApStatus{
    NSLog(@"......updateApStatus......");
    [self.tableView reloadData];
}

我在其他班级发布通知:

[[NSNotificationCenter defaultCenter] postNotificationName:@"UpdateApStatus" object:self];

错误是:

 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MenuViewController updateApStatus:]: unrecognized selector sent to instance 0xb25bf80'

我好像无法访问self

【问题讨论】:

    标签: ios6.1


    【解决方案1】:

    updateApStatus 中删除“:”。如果函数具有参数,您将只使用冒号,而您的情况并非如此。因此,添加冒号是完全不同的选择器,这就是它无法识别的原因。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-05
      • 2011-10-14
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      • 1970-01-01
      • 2018-04-12
      • 1970-01-01
      相关资源
      最近更新 更多