在ios8我使用核心數據表視圖控制器,並刪除行後,我的部分頁腳視圖突然一路下降到底部的UITableView
。當我滾動表格視圖時,頁腳視圖返回到它的位置。如何解決這個問題,爲什麼會發生這種情況?UITableView頁腳查看位置後endUpdates
這是代碼以防萬一。
- (void)controller:(NSFetchedResultsController *)controller
didChangeObject:(id)anObject
atIndexPath:(NSIndexPath *)indexPath
forChangeType:(NSFetchedResultsChangeType)type
newIndexPath:(NSIndexPath *)newIndexPath
{
if (!self.suspendAutomaticTrackingOfChangesInManagedObjectContext)
{
switch(type)
{
case NSFetchedResultsChangeInsert:
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
break;
case NSFetchedResultsChangeDelete:
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
break;
case NSFetchedResultsChangeUpdate:
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
break;
case NSFetchedResultsChangeMove:
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
break;
}
}
}
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
{
if (self.beganUpdates)
{
[self.tableView endUpdates];
}
}
看看這篇文章http://stackoverflow.com/questions/5740518/uitableview-footer-stop-from-浮動內容 – 2016-05-19 02:45:56
我提交了一個[雷達](https://openradar.appspot.com/radar?id=6187705981468672)針對這個問題。如果你想修正這個問題,我建議你們都這樣做。 Dupes非常有說服力。 – gurooj 2016-09-17 00:00:35