In einem meiner Viewcontrollers in meinem iOS-App ist ein UIButton mit dieser Funktion:UIButton arbeiten nicht in der Landschaft
@IBAction func openSettings(sender: AnyObject) {
UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!)
}
Dies ist korrekt funktioniert, aber wenn man von Hoch- auf Querformat ändert sich die Taste funktioniert nicht Mehr. Ich verwende das automatische Layout für diese Schaltfläche. Konsole sagt das:
2016-06-05 17:15:31.238 MyApp[3975:1756888] 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.
(
"<_UILayoutSupportConstraint:0x15cf4a540 V:[_UILayoutGuide:0x15cf685a0(0)]>",
"<_UILayoutSupportConstraint:0x15cd5c7d0 V:|-(0)-[_UILayoutGuide:0x15cf685a0] (Names: '|':UIView:0x15e202490)>",
"<NSLayoutConstraint:0x15cf68f60 V:[_UILayoutGuide:0x15cf685a0]-(265)-[UIButton:0x15cf65310'Enable Push!']>",
"<NSLayoutConstraint:0x15cf68fb0 UIButton:0x15cf65310'Enable Push!'.centerY == UIView:0x15e202490.centerY>",
"<NSLayoutConstraint:0x15cf4b640 'UIView-Encapsulated-Layout-Height' V:[UIView:0x15e202490(414)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x15cf68f60 V:[_UILayoutGuide:0x15cf685a0]-(265)-[UIButton:0x15cf65310'Enable Push!']>
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.
Weiß jemand oder sehen Sie den Grund?
Das hat es, es funktioniert jetzt. Ich habe die "265 Punkte von oben" gelöscht. Aber es ist sowieso seltsam, weil ich "Add miscone constrains" verwendet habe. Es muss ein Fehler in Xcode sein, oder? Jetzt bekomme ich eine Warnung: Frame "Button" wird zur Laufzeit anders sein. Aber zumindest funktioniert es. –
"fehlende Randbedingungen hinzufügen" wird am besten vermieden. Es nimmt an, was Sie wollen, tendiert aber zur absoluten Positionierung. Besser, die Einschränkungen, die Sie selbst festlegen möchten. Sie können die Rahmenwarnung loswerden, indem Sie "Rahmen aktualisieren" für das Element am unteren Rand des IB-Fensters auswählen. – Paulw11