English 中文(简体)
UITableView reload Section causes cellForRowAtIndexPath to be calls for ALLrows
原标题:UITableView reloadSection causes cellForRowAtIndexPath to be called for ALL rows

我有一张<代码>可调频密码<>,先有一栏,单行一行(即“Loading. >)。 它收集了互联网上的一些数据,当时它发出以下呼吁:

[tableView reloadSections:[NSIndexPath indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];

之所以有必要,是因为在计算数据之后,现在出现了许多增长,而不是仅仅在最初的1个增长中(因此,请表上看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看看

问题在于,它随后将cellForRowAtIndexPath 代表方法称作every one row,而不仅仅是可见的方法。 我已核实,将一些伐木纳入这一方法。 如果我把这条线改成简单的<代码>[表View reloadData],那么,它只为头几行打上了,直到你和其他人看到为止。 这发生在我的Si34iPod Touch和SOS5模拟器。

我有大约300个牢房,这非常缓慢地装载,而且通常会坠毁于我的信通。

I m不单单使用reloadData <>/code>的原因是,我希望增加新的浏览量,而reloadData。 只是突然出现这种情况。

问题回答

你可以这样做:

[tableView reloadRowsAtIndexPaths:[tableView indexPathsForVisibleRows] 
                 withRowAnimation:UITableViewRowAnimationNone]; 

这是我用来在表格中增加一行:

NSMutableArray *indexPathsToInsert = [[NSMutableArray alloc] init];

    for (NSInteger i = previousTableDataCount; i < [tableData count]; i++) {
        [indexPathsToInsert addObject:[NSIndexPath indexPathForRow:i inSection:0]];
    }

    // Apply the updates.
    [tableView beginUpdates];

    [tableView insertRowsAtIndexPaths:indexPathsToInsert withRowAnimation:UITableViewRowAnimationNone];
    [tableView endUpdates];

It doesn t reload all data, it just insert the new rows at the bottom of the existing tableView. The tableData array is the table s datasource array and the previousTableDataCount is the index with the items the tableData array had before inserting the new data from the internet...





相关问题
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, ...