Ios 约束问题

Ios 约束问题,ios,objective-c,autolayout,nslayoutconstraint,Ios,Objective C,Autolayout,Nslayoutconstraint,我创建了一个UILabel和一个UIExtField,并以编程方式添加了约束。以下是我在viewDidLoad中插入的代码: 当我运行它时,textField和label的位置不正确,我得到以下错误: 2015-06-10 22:20:17.248 myApp[2591:134955] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the followin

我创建了一个UILabel和一个UIExtField,并以编程方式添加了约束。以下是我在viewDidLoad中插入的代码:

当我运行它时,textField和label的位置不正确,我得到以下错误:

2015-06-10 22:20:17.248 myApp[2591:134955] 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:0x7f82995382d0 H:|-(0)-[UILabel:0x7f829959e320]   (Names: '|':UIView:0x7f8299450070 )>",
    "<NSLayoutConstraint:0x7f82995bd6e0 H:[UILabel:0x7f829959e320(12)]>",
    "<NSLayoutConstraint:0x7f82995bd730 H:[UILabel:0x7f829959e320]-(3)-[UITextField:0x7f82994e8bf0]>",
    "<NSAutoresizingMaskLayoutConstraint:0x7f82995d4310 h=--& v=--& UITextField:0x7f82994e8bf0.midX == + 221>",
    "<NSAutoresizingMaskLayoutConstraint:0x7f82995d4360 h=--& v=--& H:[UITextField:0x7f82994e8bf0(418)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7f82995bd730 H:[UILabel:0x7f829959e320]-(3)-[UITextField:0x7f82994e8bf0]>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-06-10 22:20:17.250 myApp[2591:134955] 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:0x7f82994edad0 H:[UIButton:0x7f829954ee80'Expense'(71)]>",
    "<NSLayoutConstraint:0x7f829953bec0 H:[UIButton:0x7f829954c6f0'Income'(71)]>",
    "<NSLayoutConstraint:0x7f82994503a0 UIButton:0x7f829954c6f0'Income'.leading == UITableViewCellContentView:0x7f82994582f0.leadingMargin>",
    "<NSLayoutConstraint:0x7f82994504b0 H:[UIButton:0x7f829954c6f0'Income']-(0)-[UIButton:0x7f829954ee80'Expense']>",
    "<NSLayoutConstraint:0x7f8299450550 UIView:0x7f8299450070.trailing == UITableViewCellContentView:0x7f82994582f0.trailingMargin>",
    "<NSLayoutConstraint:0x7f82994505a0 H:[UIButton:0x7f829954ee80'Expense']-(12)-[UIView:0x7f8299450070]>",
    "<NSLayoutConstraint:0x7f82995bd780 H:[UITextField:0x7f82994e8bf0]-(0)-|   (Names: '|':UIView:0x7f8299450070 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x7f82995d4310 h=--& v=--& UITextField:0x7f82994e8bf0.midX == + 221>",
    "<NSAutoresizingMaskLayoutConstraint:0x7f82995d4360 h=--& v=--& H:[UITextField:0x7f82994e8bf0(418)]>",
    "<NSLayoutConstraint:0x7f82995c1280 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x7f82994582f0(375)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7f82995bd780 H:[UITextField:0x7f82994e8bf0]-(0)-|   (Names: '|':UIView:0x7f8299450070 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
尝试添加:

self.view.translatesAutoresizingMaskIntoConstraints = NO;

我看到NSAutoresizingMaskLayoutConstraint,我想您不需要这些约束

什么是amountView?它的UIView或UIView内部的视图如果是主UIView,则无需对其添加约束。删除最后三行对不起。self.view中的视图我必须设置标签和文本字段的TranslateStore。。。完全没有
self.view.translatesAutoresizingMaskIntoConstraints = NO;