好吧我有這個奇怪的問題(因爲我從來沒有見過像這樣的任何錯誤),我有一個Textfield在我看來,我擴大其動畫寬度雙方(拖尾和先行),但問題是這樣的它只是從一個側面擴展(或尾隨或領導)Xcode是不讓視圖保持水平居中
我的代碼:
視圖控制器類
@IBOutlet var constraint1: NSLayoutConstraint! // textfield's leading constraint
@IBOutlet var constraint2: NSLayoutConstraint! // textfield's trailing constraint
viewDidload(){........}
@IBAction func editingBegin(sender: AnyObject) {
fullnameTextField.layer.cornerRadius = 0
fullnameTextField.clipsToBounds = false
self.constraint2.constant = -16 // here i'm expanding the width by setting constant of my Textfield
self.constraint1.constant = -16
UIView.animateWithDuration(duration) {
self.fullnameTextField.layoutIfNeeded()
}
}
我的NSLog錯誤:
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.
(
"<NSLayoutConstraint:0x155e77fb0 UITextField:0x155d85e40.trailing == UIView:0x155e46800.trailingMargin>",
"<NSLayoutConstraint:0x1546b02b0 UITextField:0x155d85e40.leading == UIView:0x155e46800.leadingMargin - 16>",
"<NSLayoutConstraint:0x1546447e0 UITextField:0x155d85e40.centerX == UIView:0x155e46800.centerX>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1546447e0 UITextField:0x155d85e40.centerX == UIView:0x155e46800.centerX>
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.
這裏是我的故事板在那裏我設置的限制
奇怪的是,我做的與其他瀏覽器同樣的事情,它在這裏工作有但不是,我檢查了他們是正確的每一個約束,並且該NSView錯誤也出現在該ViewController(上述工作正常)
任何人有任何線索最新錯誤在這裏?請讓我知道我的ViewController它如此令人沮喪
代碼http://pastebin.com/BvfEvzPE
你的主要約束應該只有'16'而尾隨將是'-16'。 –
@DipenPanchasara嘿男人你的答案訣竅 –
謝謝你。快樂編碼:) –