How to avoid Xcode gratuitous edits to storyboard files?

前端 未结 3 1012
长发绾君心
长发绾君心 2020-12-07 22:29

When I navigate to one of my xib files, Xcode marks the file as touched. Undo and revert have no effect. Saving seems to do no harm, but the glitch causes me frequent addit

3条回答
  •  自闭症患者
    2020-12-07 22:35

    I personally feel that knowing that it's a known bug doesn't exactly fix the issue. Here's what I figured out so far and how to keep them from coming up.

    NOTE: This is for a storyboard with AutoLayout enabled. I haven't yet figured it out yet for manual storyboards.

    Below is an example of a button.

    
    

    If you take a look, you'll see that the button has an element called This defines the size and position of the UI item. If you look below, you'll also see an element called that describes the change in position based on the size class. In order to fix the position for this, we have to use the following steps:

    1. Take a look at the warning that shows up in Xcode. Take note of what needs to be changed for that UI element.
    2. Open the storyboard in an external (text) editor.
    3. Find the UI element in the storyboard.
    4. Change the value to match what the warning is suggesting in both and .
    5. Save the file in the external editor.
    6. Go back to Xcode. Let it re-calculate all the constraints.
    7. Accept the warning for the UI element that pops up again.
    8. If you go back to the external editor, you'll notice that the element is gone.

    In my example, I had to update x="97" to x="597".

    I'm still working on elements that don't have a . I'll update this answer as soon as I figure it out.

提交回复
热议问题