我有一个表格视图,它位于我项目的导航视图中。 我为登录过程推送另一个视图。 此视图接受密码并将其发送到服务器进行验证。 如果密码正确,服务器将以XML格式返回一些数据。
我想用这个XML数据刷新表视图。 之前我在将navigationController视图添加到窗口之前先解析了xml。
从超级表视图中删除登录视图后,如何刷新表视图?
由于
答案 0 :(得分:1)
对于刷新表视图,您可以使用
[table reloadData];.
答案 1 :(得分:0)
(void)controllerWillChangeContent:(NSFetchedResultsController *)controller { [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];
希望有所帮助
答案 2 :(得分:0)
在将navigationController视图添加到窗口之前添加您已完成的所有代码,添加到viewWillAppear方法中,创建一个方法并从该位置调用它。