CollectionView, TableView registered classes for reuse identifiers

ぐ巨炮叔叔 提交于 2020-01-06 05:03:09

问题


I want to know which classes are registered with a UITableView or a UICollectionView with reuse identifiers

is it possible to find this info?

I've checked the class references and didn't find anything.

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


回答1:


It seems to be reuse identifier is married to Registered class when you register a class to tableview.

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

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

Discussion:

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.

If you previously registered a class or nib file with the same reuse identifier, the class you specify in the cellClass parameter replaces the old entry.

OR

You may specify nil for cellClass if you want to unregister the class from the specified reuse identifier.



来源:https://stackoverflow.com/questions/23337036/collectionview-tableview-registered-classes-for-reuse-identifiers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!