CollectionView, TableView registered classes for r

2019-08-12 08:02发布

问题:

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.