Я создал UIAlertController, как показано ниже:
let menu = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet)
menu.popoverPresentationController?.sourceView = someView!
menu.popoverPresentationController?.sourceRect = someView!.bounds
Он работает нормально, пока я не переверну устройство. (Только для iPad, потому что для iPad UIAlertController показывает всплывающее окно в позиции, зависящей от sourceView
и sourceRect
)
Когда я поворачиваю устройство, положение/размер someView
изменяется каким-то другим модулем. Поэтому есть некоторые предупреждения о ограничениях:
Unable to simultaneously satisfy constraints.
Хотя это просто предупреждение, я все же надеюсь узнать, как правильно обрабатывать UIAlertController
при изменении исходного представления?
РЕДАКТИРОВАТЬ: Журналы предупреждений об ограничениях:
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>
theController.view.hide = true
подойдет? И я должен отслеживать, открыт или закрыт контроллер? - person Joe Huang   schedule 17.05.2016UIViewController
, который отслеживал представленные всплывающие окна и события ротации. - person Sulthan   schedule 17.05.2016