CollectionView、TableView 注册类用于重用标识符 [英] CollectionView, TableView registered classes for reuse identifiers
问题描述
我想知道哪些类注册了 UITableView 或 UICollectionView 并带有重用标识符
I want to know which classes are registered with a UITableView or a UICollectionView with reuse identifiers
是否可以找到此信息?
我检查了类引用,但没有找到任何东西.
I've checked the class references and didn't find anything.
我想从 tableview 中取消注册某些类,以便用其他类替换它们.
I wanted to unregister certain classes from the tableview in order to replace them with other classes.
我知道我可以更改重用标识符,但是,我想知道是否有办法获取这些对象的注册类/笔尖
I know i can just change the reuse identifier, however, I'd like to know if there is a way to get the registered classes/nibs of these objects
推荐答案
当你将一个类注册到 tableview 时,它似乎是重用标识符与注册类的结合.
It seems to be reuse identifier is married to Registered class when you register a class to tableview.
根据苹果文档,没有开放的 API 来检查注册的类.但是你可以这样破解
According to the apple documentation there was no open API to check the registered class. But you can hack like this
UITableViewCell *cell = (UITableViewCell*)[[self.myTableView visibleCells]lastObject];
//cell.class //Your registered class
你:我想从 tableview 中取消注册某些类,以便用其他类替换它们.
You: I wanted to unregister certain classes from the tableview in order to replace them with other classes.
- (void)registerClass:(Class)cellClass
forCellReuseIdentifier:(NSString *)identifier
讨论:
在出列任何单元格之前,调用此方法或 registerNib:forCellReuseIdentifier: 方法来告诉表视图如何创建新单元格.如果指定类型的单元格当前不在重用队列中,则表视图使用提供的信息自动创建新单元格对象.
Prior to dequeueing any cells, call this method or the registerNib:forCellReuseIdentifier: method to tell the table view how to create new cells. If a cell of the specified type is not currently in a reuse queue, the table view uses the provided information to create a new cell object automatically.
如果您之前使用相同的重用标识符注册了一个类或 nib 文件,则您在 cellClass 参数中指定的类将替换旧条目.
或
如果您想从指定的重用标识符中注销类,您可以为 cellClass 指定 nil.
这篇关于CollectionView、TableView 注册类用于重用标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!