2015-09-27 72 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