English 中文(简体)
通过可上诉的书状
原标题:Looping through UITableViewCells of a UITableView

因此,我一直在试图把电池从可转让的电文上装上,并将这些电池装入一个可塑的Array号,随后再照搬。 我有一套名为“聚众”的方法,在我把6个以上的囚室投入使用之前,这些方法可进行罚款。 出于某种原因,被送回的物体为零。 我的法典如下,《全球清单》是《可转让意见》,我在第1节中将《可转让意见》分类。

- (void) populateArrayWithCells
{
for (int i = 0; i < [StocksAndAccounts numberOfRowsInSection:1]; i++) {
    if ([StocksAndAccounts cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:1]] == nil) {
        NSLog(@"object at index %i is nil", i);
    }
    [stocksCells addObject:[StocksAndAccounts cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:1]]];
}
}

This function, when called through an IBAction, returns the cell successfuly until the index is 6, in which case it is nil and crashes because it s trying to add an object that is nil. Any help with this problem would be greatly appreciated.

最佳回答

我认为,你误解了UITableView是如何运作的。 表中的囚室只有在需要展示时才会装满,并且经过回收,因此,如果你能够只看到6个囚室,那么该桌子就只能包含6个囚室,而且它只会不断更新和重新使用与你roll的6个囚室。

您的表层中不储存数据,而是将其储存在您的视力控制器中的一系列习俗物体中,并在表格要求其使用您的数据来源方法时,使用这些物体填入这些囚室。

这样,如果你永远需要将这些数据用于表上所示以外的事项,那么你就可以从原物体中重新计算数据,而不是试图将其复制到表层。

问题回答

你们正在这样做。

页: 1 (最好是一种比这更成熟的模式)应当持有你希望在<可上网读书>上显示的内容,而不是其他方式。 请审查





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

热门标签