Search code examples
iosobjective-cswiftuitableviewuisplitviewcontroller

UISplitViewController's different layout behaviour for Custom Cells in Master Controller


An UISplitViewContller's the master view controller (TAbleView) has 2 types of cell prototypes.The iOS's default one is working fine but my custom cell has layout problems so all the subviews are missing.

If I present the master view controller modally all the subviews in the cell are laid out correctly.That means it is not related with the constraints set inside the content view of the cell.

Is there something special that i need to care about?

Second cell's subview are missing.

enter image description here

How they should look like.

enter image description here

Edit:

If i debug the layoutSubviews, i see that coordinates of the labels are not right.

<UILabel: 0x7fa8f0de82f0; frame = (0 -21; 42 21); text = 'Subtitle'; 
 opaque =     NO; autoresize = RM+BM; 
 userInteractionEnabled = NO; layer = <_UILabelLayer:  0x7fa8f0de84a0>>

Constraints for the Subtitle Label

enter image description here


Solution

  • After playing around with constraints I figured out that the problem was related with the size classes.

    You need to specify the constraints for Splitview's master in ANYxANY size class not anything else.Mine were added in Regular to Any.