Xcode - Storyboard views size and position modified when opening

谁说胖子不能爱 提交于 2019-11-30 23:47:52

问题


I noticed something very annoying with Xcode: I have some storyboards for which certain views size & position are systematically updated when I open them. This is annoying especially when working with a team.

Here how I produce this behavior:

  • I pull the app from a git repository
  • Open an affected storyboard doing no modification at all
  • git diff already tells me differences like
$ git diff
...
- <rect key="frame" x="576.99999828648401" y="11" width="170" height="20"/>
+ <rect key="frame" x="577" y="11" width="170" height="20"/>
...
- <rect key="frame" x="518.99999921768904" y="7" width="228" height="30"/>
+ <rect key="frame" x="519" y="7" width="227.99999841338541" height="30"/>

Is this happening to anybody else ?

The question is:
Why is my storyboard getting modified when I'm only opening it, and how to prevent it ?


Notice:

I realized this seems to happen only on <rect /> contained into labels & textFields


回答1:


Xcode saves the storyboard layout information in an XML file (.storyboard). So any changes on the storyboard will be reflecected in that XML. Especially if you work with teammates this information might change regularly. You can try it out by moving around some items (don't change anything else) and after that start a diff with your git repository. You should see again a change in the XML. You could ignore the storyboard file in your git checkout. But this wouldn't make much sense as your teammates may have added new items to the storyboard.

Maybe this helps as well: [Xcode changes unmodified storyboard and XIB files

If I understand the first answer correct other changes might also trigger a change on the storyboard XML file.

regards Thomas




回答2:


I have the same problem. Do you resolved it? How?

This is my solution:

  1. Currently I use Xcode Version 6.1.1 (6A2008a)
  2. I download Xcode 6.3 beta 2 Build: 6D532l
  3. Open project in Xcode 6.3 beta 2
  4. Xcode 6.3 beta 2 will modify storyboard: add some fields and change some values
  5. Run project to check Application appearance
  6. Close project
  7. Open with Xcode Version 6.1.1 (6A2008a)
  8. Check changes (In my case Xcode Version 6.1.1 (6A2008a) do not decline changes by Xcode 6.3 beta 2)
  9. Run (Issue seems resolved)


来源:https://stackoverflow.com/questions/24865678/xcode-storyboard-views-size-and-position-modified-when-opening

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!