English 中文(简体)
缩略语
原标题:UITableView InsertRows (insertRowsAtIndexPaths) only animates one of two sections

在表格更新之前,我的表格数据来源只有一个部分,有一行:

  • Section 0
    • Row [0,0]

更新后,数据来源又增加了两部分,各只有一行:

  • Section 0
    • Row [0,0]
  • Section 1
    • Row [1,0]
  • Section 2
    • Row [2,0]

我使用以下代码对表格的更新进行总结:

// update the table data source, without reloading the table
UpdateTable();       

TableView.BeginUpdates();

// insert sections 1 and 2
TableView.InsertSections(NSIndexSet.FromNSRange(new NSRange(1, 2)), UITableViewRowAnimation.Fade);

// insert two new rows, one for each new section (rows [1,0] and [2,0])
TableView.InsertRows(new NSIndexPath[] { NSIndexPath.FromRowSection(0, 1), NSIndexPath.FromRowSection(0, 2) }, UITableViewRowAnimation.Fade);

TableView.EndUpdates();

然而,只有第1节及其行文被im灭。 第2节(浏览量[2,0])表面上看,没有移动/放行。 我还对“低调表”进行了核对。

该法典有什么错误?

<><>Edit>: 我想提一下的是,如果我略去<编码>InsertRows打电话,那么问题就存在了,而根据Sam的答复,这没有必要了。

最佳回答

创始原因:我正在创建新的<代码>可调频密码,每次都引用<代码>UpdateTable(<>。 情况良好,但估计表格各节和行文变动时有一些细节除外。

当我修改该守则以重新使用<代码>可调用的ViewSource例时,一切照预期。

问题回答

在插入一栏时,你不需要冲动个人行。 简言之,插入部分代码。 同样,在删除一节时,你不需要在内部删除行文。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签