猿问

iOS 使用Masonry库做动画时报错?

1.实现过程:在VCviewDidload方法中self.viewaddSubView:aLabel,viewWillLayoutSubviews中使用Masonry添加label约束;另外界面有一个button,当当点击button时候做动画.
-(void)viewDidLoad{
[superviewDidLoad];
[self.viewaddSubview:self.nameLabel];
}
-(UILabel*)nameLabel{
if(!_nameLabel){
_nameLabel=[[UILabelalloc]initWithFrame:CGRectZero];
_nameLabel.lineBreakMode=NSLineBreakByTruncatingTail;
_nameLabel.text=@"王二小";
_nameLabel.backgroundColor=[UIColorgreenColor];
_nameLabel.textAlignment=NSTextAlignmentLeft;
}
return_nameLabel;
}
-(void)viewWillLayoutSubviews{
[selfaddCContraints];
}
-(void)addCContraints{
[self.nameLabelmas_makeConstraints:^(MASConstraintMaker*make){
make.left.equalTo(self.view.mas_left).offset(10);
make.top.equalTo(self.view.mas_top).offset(10);
}];
}
//点击button的响应时间.
-(void)animationAction{
///设置长度.
[self.nameLabelmas_updateConstraints:^(MASConstraintMaker*make){
make.left.mas_equalTo(-30);
}];
[UIViewanimateWithDuration:0.3animations:^{
[self.nameLabel.superviewlayoutIfNeeded];
}];
}
**"约束冲突信息:"**
2017-08-0922:24:47.196344NSString[13501:3837010][LayoutConstraints]Unabletosimultaneouslysatisfyconstraints.
Probablyatleastoneoftheconstraintsinthefollowinglistisoneyoudon'twant.
Trythis:
(1)lookateachconstraintandtrytofigureoutwhichyoudon'texpect;
(2)findthecodethataddedtheunwantedconstraintorconstraintsandfixit.
(
"",
""
)
Willattempttorecoverbybreakingconstraint
MakeasymbolicbreakpointatUIViewAlertForUnsatisfiableConstraintstocatchthisinthedebugger.
ThemethodsintheUIConstraintBasedLayoutDebuggingcategoryonUIViewlistedinmayalsobehelpful.
跟了下Masonry执行过程也没发现什么问题.有朋友遇到过这种问题么?感谢在先.
牧羊人nacy
浏览 496回答 2
2回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答