当用户向下滚动时,我将动态地向UITableView添加单元格。它工作得很好。
我遇到的问题是,在添加新行之后,tableview会跳转。我需要它保持原样,并将新行添加到底部,我认为默认情况下会这样做。我不确定我在这里做的是不是真的做错了,或者在使用UITableViewAutomaticDimension时这是不是一个bug。
在呈现新单元格之前会有一个白色的闪光。
我的代码是

 func offerNotification(hasError : Bool?, errorDescription : String?, isCategory : String?, isComplete : Bool, isPagination : Bool, offerUpdate : NSMutableArray?){
    //Append New & Old Array
    let count = self.offersArray.count - 1
    self.offersArray.addObjectsFromArray(offerUpdate! as [AnyObject])

    //Create Array of Indexpaths
    var indexpaths : Array<NSIndexPath> = []
     for (index, _) in offerUpdate!.enumerate() {
        let nspath = NSIndexPath(forRow: count + index, inSection: 0)
        indexpaths.append(nspath)
    }

    //Add to Table
    self.tableView.insertRowsAtIndexPaths(indexpaths, withRowAnimation: UITableViewRowAnimation.Automatic)
    self.tableView.endUpdates()

}

有人经历过吗?
显示此问题的测试项目在此https://github.com/oddpanda/Endless-Scrolling-Test

最佳答案

对于遇到同样问题的人。
我的委托方法中有
解决了我所有的问题。
可能对我的问题是独一无二的,但希望它能帮助别人。

10-05 20:22