1

I designed a UITableViewController with static cells in XCode. After click on a button I want to add a row in one of the sections with a result.

My code:

InvokeOnMainThread (() => {
    List<NSIndexPath> indexPaths = new List<NSIndexPath>();
    indexPaths.Add(NSIndexPath.FromRowSection(0, 2));

    TableView.InsertRows(indexPaths.ToArray(), UITableViewRowAnimation.Fade);
});

didn't work :-) I get this error message: * Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-2380.17/UITableView.m:1070

4

1 回答 1

2

插入行后是否将数据添加到数据源(即新行或新部分)。您需要这样做,因为插入会自动执行 myTable.reloadData,从而导致再次调用所有数据源方法。如果您明确告诉它在特定索引处添加一行,然后它会重新加载并发现该索引不存在,您会收到这样的错误。检查 cellForRow 和 numCellInSection

于 2013-06-07T13:30:50.193 回答