gsdios / SDAutoLayout

One line of code to implement automatic layout. 一行代码搞定自动布局!支持Cell和Tableview高度自适应,Label和ScrollView内容自适应,致力于做最简单易用的AutoLayout库。The most easy way for autoLayout. Based on runtime.
MIT License
5.9k stars 1.28k forks source link

xib子控件布局问题 #89

Closed ToninZhao closed 8 years ago

ToninZhao commented 8 years ago

同时在父view中,布局xib子控件和代码生成的子控件,布局无效

beiguancyc commented 8 years ago

要么纯代码,要么纯xib或sb。

imantouzz commented 8 years ago

简直作死!乖乖听楼上的话

ToninZhao commented 8 years ago

既然是研究新布局,为嘛不尝试.再说用frame设置完全正常,sd布局有问题,要找原因,不是规避问题

gsdios commented 8 years ago

可以约束xib生成的控件的,把你有问题的demo发我邮箱看下 gsdios@126.com

ToninZhao commented 8 years ago

找到问题了,如果父view是代码写的,用sd布局xib子控件,要主动调[self layoutIfNeeded]; [self layoutSubviews];方法,否则布局无效

gsdios commented 8 years ago

我看了你的demo,布局代码不要写在layoutSubviews方法里面,写在初始化方法里面,约束设置一次即可,不用手动调用layoutSubviews方法的