
以下代码有什么问题?
- (UIVIEw *)tableheaderVIEw{ NSArray *constraints; UIVIEw *vIEw = [[UIVIEw alloc]initWithFrame:(CGRect){0,self.vIEw.frame.size.wIDth,88}]; UITextFIEld *tf = [[UITextFIEld alloc]init]; tf.borderStyle = UITextborderStyleRoundedRect; tf.text = _filter.name; [vIEw addSubvIEw:tf]; UILabel *TitleLabel = [[UILabel alloc] init]; TitleLabel.textAlignment = NSTextAlignmentCenter; TitleLabel.translatesautoresizingMaskIntoConstraints = NO; TitleLabel.text = [Nsstring stringWithFormat:NSLocalizedString(@"Found results: %d",nil),_filter.resultsCount]; [vIEw addSubvIEw:TitleLabel]; constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-[TitleLabel]-|" options:0 metrics:nil vIEws:NSDictionaryOfVariableBindings(TitleLabel)]; [vIEw addConstraints:constraints]; constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-[tf]-|" options:0 metrics:nil vIEws:NSDictionaryOfVariableBindings(tf)]; [vIEw addConstraints:constraints]; constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[TitleLabel]-8-[tf]|" options:0 metrics:nil vIEws:NSDictionaryOfVariableBindings(TitleLabel,tf)]; [vIEw addConstraints:constraints];} 错误信息:
Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following List is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSautoresizingMaskLayoutConstraints that you don't understand,refer to the documentation for the UIVIEw property translatesautoresizingMaskIntoConstraints) ( "<NSLayoutConstraint:0x15dd2fc0 V:|-(0)-[UILabel:0x15dd1e10] (names: '|':UIVIEw:0x15dc4f90 )>","<NSLayoutConstraint:0x15dd3120 V:[UILabel:0x15dd1e10]-(8)-[UITextFIEld:0x15dbe780]>","<NSautoresizingMaskLayoutConstraint:0x15de2300 h=--& v=--& UITextFIEld:0x15dbe780.mIDY ==>")Will attempt to recover by breaking constraint <NSLayoutConstraint:0x15dd3120 V:[UILabel:0x15dd1e10]-(8)-[UITextFIEld:0x15dbe780]>Break on objc_exception_throw to catch this in the deBUGger.The methods in the UIConstraintBasedLayoutDeBUGging category on UIVIEw Listed in <UIKit/UIVIEw.h> may also be helpful.2014-07-14 14:01:30.216 DossIErPolice[4724:60b] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following List is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSautoresizingMaskLayoutConstraints that you don't understand,refer to the documentation for the UIVIEw property translatesautoresizingMaskIntoConstraints) ( "<NSLayoutConstraint:0x15dd2e20 H:[UITextFIEld:0x15dbe780]-(Nsspace(20))-| (names: '|':UIVIEw:0x15dc4f90 )>","<NSautoresizingMaskLayoutConstraint:0x15de1ee0 h=--& v=--& UITextFIEld:0x15dbe780.mIDX ==>","<NSautoresizingMaskLayoutConstraint:0x15de22d0 h=--& v=--& H:[UITextFIEld:0x15dbe780(0)]>","<NSautoresizingMaskLayoutConstraint:0x13a9eda0 h=--& v=--& H:[UIVIEw:0x15dc4f90(320)]>")Will attempt to recover by breaking constraint <NSLayoutConstraint:0x15dd2e20 H:[UITextFIEld:0x15dbe780]-(Nsspace(20))-| (names: '|':UIVIEw:0x15dc4f90 )>Break on objc_exception_throw to catch this in the deBUGger.The methods in the UIConstraintBasedLayoutDeBUGging category on UIVIEw Listed in <UIKit/UIVIEw.h> may also be helpful.2014-07-14 14:01:30.217 DossIErPolice[4724:60b] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following List is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSautoresizingMaskLayoutConstraints that you don't understand,refer to the documentation for the UIVIEw property translatesautoresizingMaskIntoConstraints) ( "<NSLayoutConstraint:0x15dd3160 V:[UITextFIEld:0x15dbe780]-(0)-| (names: '|':UIVIEw:0x15dc4f90 )>","<NSautoresizingMaskLayoutConstraint:0x15de2300 h=--& v=--& UITextFIEld:0x15dbe780.mIDY ==>","<NSautoresizingMaskLayoutConstraint:0x15de2330 h=--& v=--& V:[UITextFIEld:0x15dbe780(0)]>","<NSautoresizingMaskLayoutConstraint:0x13a9ee00 h=--& v=--& V:[UIVIEw:0x15dc4f90(88)]>")Will attempt to recover by breaking constraint <NSLayoutConstraint:0x15dd3160 V:[UITextFIEld:0x15dbe780]-(0)-| (names: '|':UIVIEw:0x15dc4f90 )>Break on objc_exception_throw to catch this in the deBUGger.The methods in the UIConstraintBasedLayoutDeBUGging category on UIVIEw Listed in <UIKit/UIVIEw.h> may also be helpful.解决方法 你忘了在tf上将translatesautoresizingMaskIntoConstraints设置为NO.此属性可防止布局引擎自动将旧样式自动调整掩码转换为约束,这就是错误的原因. 总结
以上是内存溢出为你收集整理的ios – Autolayout约束冲突全部内容,希望文章能够帮你解决ios – Autolayout约束冲突所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)