사용자가/4로 돌아갈 수있는 UINavigationController가 있습니다. 사용자가 돌아 가면 해당 UIView를 다시로드해야합니다. (실제로는 OHGridView을 사용하고 있습니다). 그들이 돌아갈 때어떻게 UIView를 다시로드합니까?
- (void)viewWillDisappear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReloadOHGridView" object:self];
}
그래서, 그것은 데이터의 갱신하기 위해 OHGridView에 NSNotification 보내드립니다 : 내 ViewWillDisappear
, 나는 이런 일을한다. 그것은의라는 얻을 수 있지만,의에게 오류 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DetailViewController reloadData]: unrecognized selector sent to instance 0x4b9e9f0
를 얻을 여기 (내 DetailViewController에) 내 NSNotificationCenter를 설정하는 방법은 다음과 같습니다
- (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];
}
지금 당신이 업데이트 것이라고 생각하지만, 난 그 오류 ... 도와주세요!
쿨턴
고마워요! IBOutlet을 다음과 같이 만들었습니다 :'IBOutlet OHGridView * ohGridView;'와 같이 새로 고침을했습니다 :'[ohGridView reloadData]'... 다른 사람이 같은 문제를 일으키는 지 확인하십시오! – iosfreak
달콤한! 행운을 빕니다. – CharlieMezak