你怎么重装UIView?

时间:2011-04-13 01:04:44

标签: xcode ios4 uiview nsnotificationcenter reloaddata

我有一个UINavigationController,用户可以返回/第四。当用户返回时,我希望UIView重新加载。 (我实际上正在使用OHGridView)。在我ViewWillDisappear上,我做了类似的事情:

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

因此,当他们返回时,它会向OHGridView发送NSNotification以刷新其数据。它被调用,但它是一个错误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];
}

现在你会认为它会更新,但我收到了这个错误......请帮忙!

库尔顿

1 个答案:

答案 0 :(得分:3)

实际上,我认为它不会更新。 reloadData不是UIViewController的文档化方法的名称,您似乎自己没有实现它。我不熟悉OHGridView,但我可能那是你想要发送reloadData消息的对象。

因此,您可以将您从self设置的观察者更改为您的OHGridView实例,或者您可以在视图控制器中实现一个名为reloadData的方法,该方法又将相应的重新加载消息发送到你的OHGridView。

相关问题