我动态地添加单元格到我的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