当用户在平面囚室上下滚动时 被摧毁并创造出来
是否有一种方法可以探测牢房何时将被摧毁或是否已被摧毁?
当用户在平面囚室上下滚动时 被摧毁并创造出来
是否有一种方法可以探测牢房何时将被摧毁或是否已被摧毁?
假设您在“ 正在被销毁” 中实际上指的是正在被再利用的单元格, 只需在您的 < code> TableViewCell code > 衍生类中执行 < code> prepare for Reuse 。
<坚固 > 准备再使用 坚固 >
准备一个可重复使用的单元格,供表格查看的代表重新使用。
- (void)prepareForReuse
<强度 > 讨论 强度>
If a UITableViewCell object is reusable—that is, it has a reuse identifier—this method is invoked just before the object is returned from the UITableView method dequeueReusableCellWithIdentifier:. For performance reasons, you should only reset attributes of the cell that are not related to content, for example, alpha, editing, and selection state. The table view s delegate in tableView:cellForRowAtIndexPath: should always reset all content when reusing a cell. If the cell object does not have an associated reuse identifier, this method is not called. If you override this method, you must be sure to invoke the superclass implementation.
Availability Available in iOS 2.0 and later. See Also – initWithFrame:reuseIdentifier: @property reuseIdentifier Declared In UITableViewCell.h
在不触及适用性或性能的影响的情况下,另一种选择可能是利用UITableView 类的可见单元格方法,定期检查哪些单元格仍然可见:
- (NSArray *)visibleCells
根据文件:
返回包含 UITableViewCell 对象的数组,每个数组代表接收表格视图中的可见单元格。
您可以使用 >UITViewCell
的子类并推翻其 dealloc
方法。
假设你正在利用细胞来节省资源 是否有合理的理由这样做?
你试图拦截的东西是UITView内部实施的一部分,以及它如何管理其细胞的一部分。虽然有办法你可以试图拦截这种行为,但我建议你避免使用它们,因为无法保证UITView的未来实施将维持这种行为。
在这种情况下,最好考虑一种不同的做法:无论是设计和实施自己的表格类别,还是改变你的代码逻辑。
如前所述,在离开屏幕时,细胞不会被摧毁,但是,根据您想要做什么,你可以做一些事情,跟踪相关的行动。
首先,有一条代表信息:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
这是在单元格进入屏幕之前调用的。另一种可能性是已经声明的单元格准备重新使用方法。
另一种办法是:尝试和重置将移动到审阅:或者其他任何相关方法。我不知道在细胞隐形后是否会发射,但也许会有效。
Best regards, Michael
For a basic app with nonconsumable in-app purchases, has anyone figured out best practices for using SKPaymentQueue s restoreCompletedTransactions? Observations I know it s recommended to always ...
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: - (...
I have a UITextField that is a subview of a UITableViewCell. When my view loads, I want the text field to become first responder. I have a pointer to the text field in the table cell, so to do this I ...
I ve been working on adding in-app purchases and was able to create and test in-app purchases using Store Kit (yay!). During testing, I exercised my app in a way which caused the app to crash mid ...
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). ...
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 ...
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:...
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, ...