Error: UITableView jump to top with UITableViewAutomaticDimension

前端 未结 7 1712
半阙折子戏
半阙折子戏 2020-12-05 15:17

I am using UITableView with estimatedRowHeight and UITableViewAutomaticDimension. Also I am using NSFetchedResultsControllerDele

7条回答
  •  借酒劲吻你
    2020-12-05 15:19

      func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {
        switch type {
        case .Insert:
    
          tableView.insertRowsAtIndexPaths([newIndexPath!], withRowAnimation: .None)
            break
    
        case .Update:
            tableView.reloadRowsAtIndexPaths([indexPath!], withRowAnimation: .None)
            break
    
        case .Delete:
            tableView.deleteRowsAtIndexPaths([indexPath!], withRowAnimation: .None)
            break
    
        default: break;
        }
       tableView.reloadData()
      let indexPath = NSIndexPath(forRow: 0, inSection: 0)
      self. tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: .Top, animated: true)
       }
    
    }
    

提交回复
热议问题