Ich habe einen UIAlertController wie folgt:Wie behandelt man `UIAlertController` richtig, wenn die Quellansicht geändert wird?
let menu = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet)
menu.popoverPresentationController?.sourceView = someView!
menu.popoverPresentationController?.sourceRect = someView!.bounds
Es funktioniert gut, bis ich das Gerät drehen. (IPAD nur, weil für IPAD, die UIAlertController zeigt ein popover an einer Position in Abhängigkeit von sourceView
und sourceRect
)
Wenn ich das Gerät dreht, wird die Position/Größe des durch ein anderes Modul verändert. Daher gibt es einige Warnungen über contraints:
Unable to simultaneously satisfy constraints.
Obwohl es nur warnen, ich hoffe immer noch zu wissen, was der richtige Weg ist UIAlertController
zu handhaben, wenn die Quelle Ansicht geändert wird?
EDIT: Protokolle für die Einschränkung Warnungen:
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)
(
"<NSAutoresizingMaskLayoutConstraint:0x7fac14c672f0 UIView:0x7fac14c994c0.width == 19>",
"<NSLayoutConstraint:0x7fac14c95260 UIView:0x7fac1483b430.width == 300>",
"<NSLayoutConstraint:0x7fac124f8520 _UIAlertControllerView:0x7fac14c41cc0.width == UIView:0x7fac14c994c0.width>",
"<NSLayoutConstraint:0x7fac14c09ac0 _UIAlertControllerView:0x7fac14c41cc0.width >= UIView:0x7fac1483b430.width>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fac14c95260 UIView:0x7fac1483b430.width == 300>
Welche Einschränkungen sind falsch genau? Können Sie uns den Code zeigen, der den Fehler erzeugt? – Sulthan
was willst du erreichen? –
@Sultan siehe EDIT Teil –