English 中文(简体)
SDK: 如何在看不见的表格中找到一个电池?
原标题:iOS SDK: How to get a cell in a table view that is not visible?

How do I get the cell for an indexPath which is not currently visible in the table? (cell is out of range)

接见我的囚室:

NSString *name = [[(ELCTextfieldCell *)[tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]] rightTextField] text];

。 由于所需指数Path的电池范围不一。 因此,我如何获得正确的牢房,而不是 n?

最佳回答

这并不是它是如何运作的。 一旦信息输入或改变,你就需要抓捕和储存。 它可能很容易脱离范围,你不能保证你的囚室长寿。 从技术上讲,你可以保留(而且总是回到同一个指数轨道上的同一个单元),但我质疑这一设计。

问题回答

。 如您需要一个显示器,请打电话tableView:cellForRowAtIndexPath:。 因此,如果自成一类,即<代码>数据/代码>:

UITableViewCell * cell = [self tableView:table cellForRowAtIndexPath:indexPath];

UITableViewCells are made to be reused/recycled in a way that the users won t need to create more cells than the number of visible ones. You usually don t need to access a cell that is not visible. It should be enough you access your datasource and get/set the correspondent data there. Cells are for showing some state of the datasource. Not the datasource itself :)

Edit:

你们说,你们需要从上面一个单元获得一些信息(文本)。 如果您使用cellForRowAtIndexPath: 单元将重新计算,但你可能无法获得正文中的案文。 原因? 或许,你在其他地方没有钱。 如果你节省了这笔钱,那么就能够直接进入,而不是通过牢房。

在继续回答@Raphael时,这里是(工作)swift 3。 解决办法:

UITableViewCell cell = Self.tableView(自称)。 View, cellForRowAt:indexPath

填补您的席位的信息来自一阵列吗? 难道你不能把这套阵列直接从0个指数中删除,就像你为“ForRowAtIndexPath”而做的那样,在显示该囚室时,大概会找回和填充。





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

热门标签