0
我試圖在表格的開頭插入一行,但我想保持以前內容的位置(類似於Twitter應用程序時負載更多的鳴叫),此刻我正在使用下面的代碼:將行插入到UITableView而不更改之前內容的位置
- (void) insertObject: (id) object
{
[_objects insertObject: object atIndex: 0];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
[[self tableView] insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
問題是什麼? – Eimantas
我認爲他會保留插入後的實際位置。 所以如果tableview顯示單元格1-5並且他在位置0上插入一行。那麼可見行應該是1-5而不是0-4。 – mafis
沒錯,問題是在顯示的行之前插入行後保持當前位置。 – xlarsx