Krishna Kumar Krishna Kumar - 4 months ago 38
iOS Question

Create multiple collectionviewcells with single XIB and class

I have created the basic designing of custom cell in XIB with all views that a cell can have. Say, I have three subviews and trying to create three different cells by hiding each view for respective cells. But when the cell1 is getting reused on the position where cell2 should be presented in that case my autolayout constraints gets updated but not reflect the changes in UI. But these constraints changes work when its creating all different cells for the first time.

Can anyone tell me even if its possible to do so or not?

Two approaches I can think of achieving this behavior
1. Either I create different XIBs for different kind of cell with different reuse identifier and attached to that customCell Class. But in this case I can have more than 15 different cells.

  1. The approach I am using put all the subviews in a custom cell in XIB and then alter your constraints to achieve different kind of cells. But I have explained my problem in above explanation.My custom Cell where I can show the last two buttons and not


I have used different reuse identifier for like cells and then created multiple XIB wherever height is getting affected. And also playing with constraints to hide buttons and show buttons and everything.