2016-02-24 67 views
0
table.beginUpdates() 
array.removeLast() 
table.deleteRowsAtIndexPaths([anIndexPath], withRowAnimation: UITableViewRowAnimation.None) 
for object in container { 
    array.append(object) 
} 
array.append("New Object") 
table.insertRowsAtIndexPaths([Set of IndexPaths]), withRowAnimation: UITableViewRowAnimation.Fade) 
table.endUpdates() 

我正在使用上面的代碼。它工作正常,但唯一的問題是動畫。執行上面的代碼行後,表格視圖滾動位置設置爲頂部。不知道如何。受到歡迎。UITableView動畫無法正常工作

+0

是否使用'控制器上self.tableView.estimatedRowHeight'方法幫你嗎?這種方法之前我有同樣的問題。 – thedjnivek

+0

您是否僅在iOS 8中遇到此問題? – Skywalker

+0

@MeharoofNajeeb我的應用程序僅支持iOS 9+ –

回答

0

我必須設置該屬性之前這個問題:self.tableView.estimatedRowHeight

如果您正在使用,請嘗試將控制器上添加此方法來防止這種失望的。

func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { 
    return UITableViewAutomaticDimension 
} 

希望這可以

+0

只有當他使用AutomaticDimension時,這纔是解決方案。 – Skywalker

+1

是的,我同意你的意見。我有這樣的問題。如果他不使用estimatedHeightForRow,我不能幫助他.. – thedjnivek

+0

我使用相同的。 table.rowHeight = UITableViewAutomaticDimension table.estimatedRowHeight = 500.0 –