2015-09-27 69 views
1

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

+0

调用'beginUpdates'方法在哪里? – Abizern

+0

在标准函数中,当检测到'uitableview'在底部时'func offerNotification(hasError:Bool?,errorDescription:String ?, isCategory:String ?, isComplete:Bool,isPagination:Bool,offerUpdate:NSMutableArray?) {'会添加我的代码。 – Allreadyhome

回答

-1

对于任何人遇到了同样的问题,我有。

我在我的委托方法estimatedHeightForRowAtIndexPath当被删除 修复了我所有的问题。

对我的问题可能是独一无二的,但希望它可以帮助某人。

+0

这是downvoted,因为? – Allreadyhome

+0

我误解了一些东西吗?当我为自己的问题得到正确答案时,如何才能正确回答它? – Allreadyhome