我有一個表格視圖在我的項目中的導航視圖。 我推入另一個視圖進行登錄。 該視圖接受密碼並將其發送到服務器進行驗證。 如果密碼正確,服務器將返回XML中的一些數據。如何刷新/更新登錄視圖後的tableview?
我想用這個XML數據刷新表視圖。 以前,我在將navigationController視圖添加到窗口之前先解析了xml。
如何從超級表視圖中刪除我的登錄視圖後刷新表視圖?
由於
我有一個表格視圖在我的項目中的導航視圖。 我推入另一個視圖進行登錄。 該視圖接受密碼並將其發送到服務器進行驗證。 如果密碼正確,服務器將返回XML中的一些數據。如何刷新/更新登錄視圖後的tableview?
我想用這個XML數據刷新表視圖。 以前,我在將navigationController視圖添加到窗口之前先解析了xml。
如何從超級表視圖中刪除我的登錄視圖後刷新表視圖?
由於
(無效)controllerWillChangeContent:(NSFetchedResultsController *)控制器{ [self.table1View beginUpdates]; }
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo
atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {
switch(type) {
case NSFetchedResultsChangeInsert:
[self.table1View insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
break;
case NSFetchedResultsChangeDelete:
[self.table1View deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
break;
}
}
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
newIndexPath:(NSIndexPath *)newIndexPath {
UITableView *tableView = self.table1View;
switch(type) {
case NSFetchedResultsChangeInsert:
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
break;
case NSFetchedResultsChangeDelete:
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
break;
case NSFetchedResultsChangeUpdate:
[self configureCell:[tableView cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
break;
case NSFetchedResultsChangeMove:
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]withRowAnimation:UITableViewRowAnimationFade];
break;
}
}
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
[self.table1View beginUpdates];
}
,如果你有這個功能,你可以使用[self.YourTableView reloadData];
希望它可以幫助
添加所有您已加入navigationController視圖窗口之前完成的代碼,爲您的viewWillAppear中的方法,製作一個方法並從兩個地方調用它。
對於刷新表查看您可以使用
[table reloadData];.
我使用下面的代碼。但我得到'tableView'未聲明的錯誤。我沒有聲明的tableView。我的主窗口從我的另一個nib文件加載表視圖。任何想法? - (void)viewWillAppear:(BOOL)animated { \t [super viewWillAppear:animated]; \t \t [tableView reloadData]; } – astk 2011-02-23 16:08:09
在IB.i中聲明你的tableview的意思是使用IBoutlet UItableView * table;並映射它,並將委託方法連接到filesowner.if它在另一個類中Syntesis你的tableview,並創建一個實例到當前類的那個類。你可以重新加載表。 – Sat 2011-02-24 05:14:30
你是什麼意思做的方法,並調用它?這種方法應該做什麼?我試圖與viewWillAppear回調也。但是在我刪除了登錄視圖之後,底層的導航視圖的viewWillAppear方法不被觸發。你能詳細說明這些嗎?非常感謝。 – astk 2011-02-24 01:32:43