What impact does simulated metrics have?

后端 未结 3 1317
小蘑菇
小蘑菇 2020-12-01 15:58

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?

3条回答
  •  离开以前
    2020-12-01 16:49

    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:

    
    

    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
    >
    
    
    // viewWillAppear
    (lldb) po splashImageView
    >
    

    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
    >
    

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

提交回复
热议问题