我動態地添加單元格到我的UITableView當用戶向下滾動。它工作完美。insertRowsAtIndexPaths跳轉與自定義單元格UITableView和UITableViewAutomaticDimension
我遇到的問題是,新行添加後,tableview跳轉。我需要它保持原位,並將新行添加到底部,我認爲這會默認完成。我不知道我在這裏做了些什麼錯誤,或者如果這是使用UITableViewAutomaticDimension
時的錯誤。
在新單元格呈現之前會出現白色閃爍。
我的代碼是
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
調用'beginUpdates'方法在哪裏? – Abizern
在標準函數中,當檢測到'uitableview'在底部時'func offerNotification(hasError:Bool?,errorDescription:String ?, isCategory:String ?, isComplete:Bool,isPagination:Bool,offerUpdate:NSMutableArray?) {'會添加我的代碼。 – Allreadyhome