XCode 6.3 adding margins to tableviewcell

前端 未结 1 1836
我在风中等你
我在风中等你 2020-12-13 22:26

Did XCode 6.3 / Swift 1.2 add additional margins to a UITableViewCell\'s contentView? Prior to updating, I had a custom UIView that extended all the way across the screen in

1条回答
  •  醉梦人生
    2020-12-13 23:22

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

    enter image description here

    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.

    0 讨论(0)
提交回复
热议问题