ios - A smart way to configure custom cells on table load-up? -
I have a table view with about 5 different custom cells, which are designed in the storyboard.
Each of these cells has its own dedicated subclass of The problem now is, I want to call It is possible to cast each cell type individually, but with lots of Of course, more flexible than I think this sub-Clasing with a protocol, but It depends on the words of each cell class, and you can always mix and match in both ways. In the cell creation method: UITableViewCell .
cellForRowAtIndexPath , I dequeue cells:
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: self.cellArray [indexPath.row] forIndexPath: indexPath];
configureCell for each of these cells have declared this method in my other custom cell classes and implemented but the problem is that XCode throws up a warning when I do these cells with respect to not put in their respective classes in the cells, because XCode
UITableViewCell cells.
if and
else if lines, what is verbose do A clever way, maybe a method
configureCell ?
@protocol CellX - Configure (zero): (id) information; @ And @ interfaces cell a: uitable vixel & lt; Cellx & gt; @and @InterfaceSellb: UITTable Wexels & lt; Cellx & gt; @end
NSString * identifier = / * index and whatnot * / id & lt; CellX & gt; Cell = (id & lt; cellX & gt;) [tableview dequeueReusableCellWithIdentifier: & lt; # Identifier # & gt; ForIndexPath: indexPath]; / * The cell class can be either cell or cellB, which is the selected identifier * / [cell configured: & lt; # Data # & gt;]; In addition to the configuration method, you can add any asset to the protocol that is shared in the cell (like
kind ,
status etc., whatever you use to deal with cells).
Comments
Post a Comment