Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What impact does simulated metrics have?

Tags:

When using .xib files what impact on your code/app does changing simulated metrics have? Or is it just for your benefit as a preview tool?

like image 709
drc Avatar asked Apr 29 '13 13:04

drc


1 Answers

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.

like image 84
Hugo Avatar answered Sep 21 '22 02:09

Hugo