NSNotification과 viewWillAppear/viewDidAppear의 조합을 사용하는 것이 좋습니다.
viewWillAppear는 경우 -의 tableview를 다시로드 뷰가 등장하면
- (void)viewWillAppear:(BOOL)animated
{
// Your other code here...
[self.tableview reloadData];
}
및 백그라운드에서 데이터가 변경됩니다 (당신이 마지막으로 데이터를 표시하기 때문에 당신은 데이터의 변화에 대한보고를 수정할 수 있음) 다른 객체 - 직후 (이 같은/사후 통지를 보내야합니다 viewWillDisappear에서 viewWillAppear에서 그 notificaiton에 대한
다른 객체를 & 등록 취소를 통지하고있는 tableview의의 ViewController 레지스터를 보내 해당 개체를 물어 데이터 변경) - 테이블이 당신의 ViewController (에
[[NSNotificationCenter defaultCenter] postNotificationName:@"com.yourcompany.appname.XYZdataChangeNotification" object:nil];
모든 아래 코드)를 업데이트 할 -
등록을 다음과 같이 -
- (void)viewWillAppear:(BOOL)animated
{
// Your other code here...
[self.tableview reloadData];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNewDataReceivedNotification:) name:@"com.yourcompany.appname.XYZdataChangeNotification" object:nil];
}
알림 처리기를보기 컨트롤러에서 -
- (void)handleNewDataReceivedNotification:(NSNotification *)notification
{
// Your other code here...
[self.tableview reloadData];
}
그리고 등록 취소 -
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"com.yourcompany.appname.XYZdataChangeNotification" object:nil];
}
위의 코드는 모두 수정 될 수 있지만 아이디어가 있어야합니다. 문의 사항이 있으시면 언제든지 문의하십시오.
귀하는이 포럼에서 처음이므로 질문을 게시 한 후 다시 방문하여 위 또는 아래로 동의하거나 투표를해야합니다. 피드백은 중요합니다. – Ashok