为什么NSLayoutConstraint在UIView 上不起作用

NSLayoutConstraint *leftSpace =[NSLayoutConstraint
                                    constraintWithItem:_unloadBtn
                                    attribute:NSLayoutAttributeCenterY
                                    relatedBy:NSLayoutRelationEqual
                                    toItem:self
                                    attribute:NSLayoutAttributeCenterY
                                    multiplier:1
                                    constant:0];
    //    NSArray *selfConstraints=@[leftSpace];
    [self addConstraint:leftSpace];

虽然没有报错,但是不起作用。
几个问题

  1. 我想做一个 view 来嵌入到UITableViewCell中,刚开始用的viewcontroller,但是把对象数据赋给view的时候,view controller那个类总是null。(在viewcell的layoutsubview中赋值的)失败后看案例是直接用UIView.我就用UIView试试。
  2. UIview中使用NSLayoutConstraint,不知道咋弄的,望大神指点一下。
阅读 5k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题