What impact does simulated metrics have?

Well actually changing the Simulated Metrics does impact your application in a very sneaky way. I found that out while using the SwipeView library and my slides were all impacted by changing the Simulated Metric size.

Under the hood changing that size sets the rect value of the nib file as such:

<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>

That value is gonna be the size the nib launches. If we try to measure elements in view did load and view will appear we will have false information:

// viewDidLoad
(lldb) po splashImageView
<UIImageView: 0x79913eb0; frame = (0 0; 600 600); autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x799ca310>>


// viewWillAppear
(lldb) po splashImageView
<UIImageView: 0x79913eb0; frame = (0 0; 600 600); autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x799ca310>>

Once the layout subviews is done we do have the proper size but as far as SwipeView is concerned it’s too late it already calculated the position of everything.

// viewDidLayoutSubviews
(lldb) po splashImageView
<UIImageView: 0x79913eb0; frame = (0 0; 768 1024); autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x799ca310>>

If anyone can provide more information I’d really like it.

Leave a Comment