NSLayoutConstraint *leftSpace =[NSLayoutConstraint
constraintWithItem:_unloadBtn
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:NSLayoutAttributeCenterY
multiplier:1
constant:0];
// NSArray *selfConstraints=@[leftSpace];
[self addConstraint:leftSpace];
虽然没有报错,但是不起作用。
几个问题
- 我想做一个 view 来嵌入到UITableViewCell中,刚开始用的viewcontroller,但是把对象数据赋给view的时候,view controller那个类总是null。(在viewcell的layoutsubview中赋值的)失败后看案例是直接用UIView.我就用UIView试试。
- UIview中使用NSLayoutConstraint,不知道咋弄的,望大神指点一下。
_unloadBtn 是否设置了
autolayout建议学习Masonry,附上一位大牛的文章,Masonry介绍与使用实践(快速上手Autolayout)