最近花了很长时间来调试界面布局问题。
自己写的一个View,怎么都无法让它正确的摆放。
到最后发现是layoutSubviews引起的。
SDK帮助文档中写道:
p.p1 {margin: 0.0px 0.0px 10.0px 0.0px; font: 13.0px 'Lucida Grande'}
You should override this method only if the autoresizing behaviors of the subviews do not offer the behavior you want.
反过来的意思就是说:如果你想要在外部设置subviews的位置,就不要重写这个函数。
我把重写的函数删掉,一切终于归为正常了。
PS:如果是写自定义TableViewCell,则必须重写则换个函数,否则位置会发生偏转。
这个函数还需要深入了解。