XCode 6.3 adding margins to tableviewcell

两盒软妹~` 提交于 2019-11-28 18:59:17

Look carefully at this screen shot of the Size inspector for a leading constraint:

See how "Relative to margin" is checked? That's your problem. If the margin changes, your left edge changes. Uncheck that menu item and then change the Constant to zero. Do that for the trailing constraint too, and your problems will be over.

Now let's address the deeper issue: what changed? You are absolutely right, something did. I believe they fixed a bug, and you got caught in the fix. Logging shows me that the cell's preservesSuperviewLayoutMargins is true and that the table's margins are 0,16,0,16. This is true even on iOS 8.2, so the effective margins on iOS 8.2 should have been 16. But they were 8, as if preservesSuperviewLayoutMargins were false. But in iOS 8.3, this setting is obeyed properly — with the result that you have observed.

Thus, another way to fix the problem would have been to leave your constraints as they are, but to set each cell's preservesSuperviewLayoutMargins to false in cellForRowAtIndexPath:. This works equally well to make the outcome identical in both systems.

EDIT Good news: it looks like this change is reverted in iOS 9. Thus, without change, your cells would look the same in iOS 9 as they did in iOS 8.2 and before.

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