2011-04-13 84 views
0

我有一个UINavigationController用户可以返回/第四。当用户返回时,我希望该UIView重新加载。 (我实际上使用的是OHGridView)。在我ViewWillDisappear,我做这样的事情:如何重新加载UIView?

- (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]; 
} 

现在,你可能会认为这将更新,但我得到这个错误...请帮忙!

库尔顿

回答

3

其实,我不认为它会更新。 reloadData不是UIViewController的文档化方法的名称,而且您自己似乎也没有实现过。我对OHGridView并不熟悉,但我也许是要发送reloadData消息的对象。

所以,你可以改变你从self建立到OHGridView实例观察者,或者你可以在你叫reloadData,反过来发送适当的重载邮件到您的OHGridView视图控制器实现的方法。

+0

谢谢!我创建了一个IBOulet,像这样:'IBOutlet OHGridView * ohGridView;'并调用像这样的刷新:'[ohGridView reloadData]'...只要告诉任何人都有同样的问题! – iosfreak 2011-04-13 01:18:01

+0

甜!祝你好运。 – CharlieMezak 2011-04-13 01:27:53