With autolayout, label position is reset when I change label text

后端 未结 2 1698
走了就别回头了
走了就别回头了 2020-12-19 17:56

I am developing a very simple application in Objective-c.
In the app, the user can change a position of the label by dragging the screen.

Tap & drag the scre

2条回答
  •  温柔的废话
    2020-12-19 18:45

    You cannot use auto layout and change the center / frame of things; those are opposites. Do one or the other - not both.

    So, you don't have to turn off auto layout, but if you don't, then you must use auto layout, and auto layout only, to position things.

    When you move the label, do not change its center - change its constraints. Or at least, having changed its center, change its constraints to match.

    Otherwise, when layout occurs, the constraints will put it back where you have told them to put it. And layout does occur when you change the text, and at many other times.

提交回复
热议问题