0

ユーザーが前後に移動できる UINavigationController があります。ユーザーが戻ったら、その UIView をリロードします。(私は実際にOHGridViewを使用しています)。私のViewWillDisappearでは、次のようなことを行います。

- (void)viewWillDisappear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReloadOHGridView" object:self];
}

そのため、戻ると、NSNotification が OHGridView に送信され、データが更新されます。呼び出されますが、エラーになりますTerminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DetailViewController reloadData]: unrecognized selector sent to instance 0x4b9e9f0

NSNotificationCenter を (DetailViewController で) セットアップする方法は次のとおりです。

- (void)viewDidLoad {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ReloadGridNotification:) name:@"ReloadOHGridView" object:nil];
}

- (void)ReloadGridNotification:(NSNotification *)notification{

    [database executeNonQuery:@"DELETE * FROM images"];
    [items removeAllObjects];

    [self reloadData];
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

更新されると思うかもしれませんが、そのエラーが発生します...助けてください!

コールトン

4

1 に答える 1

3

実は、更新されるとは思いません。reloadDataはUIViewControllerの文書化されたメソッドの名前ではなく、自分で実装したようには見えません。私はOHGridViewに精通していませんが、おそらくそれがreloadDataメッセージの送信先のオブジェクトです。

したがって、設定したオブザーバーをselfOHGridViewのインスタンスに変更するか、View Controllerにメソッドを実装してreloadData、適切なリロードメッセージをOHGridViewに送信することができます。

于 2011-04-13T01:08:25.913 に答える