Предупреждения при выходе из диалога UIAlertController - PullRequest
0 голосов
/ 02 апреля 2019

Я реализовал код веб-сайта разработчика Apple для UIAlertController,

let alert = UIAlertController(title: "My Alert", message: "This is an alert.", preferredStyle: .alert) 
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Default action"), style: .default, handler: { _ in 
NSLog("The \"OK\" alert occured.")
}))
self.present(alert, animated: true, completion: nil)

и получаю следующие предупреждения после нажатия кнопки «ОК» в диалоговом окне,

2019-04-02 14:30:15.034840+0100 kiosk[7873:3437019] [LayoutConstraints] 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:0x280db0780 h=--& v=--& UIKeyboardAssistantBar:0x105327350.height == 0   (active)>",
    "<NSLayoutConstraint:0x280df8c30 V:|-(0)-[_UIButtonBarStackView:0x105327c80]   (active, names: '|':UIKeyboardAssistantBar:0x105327350 )>",
    "<NSLayoutConstraint:0x280df8be0 V:[_UIButtonBarStackView:0x105327c80]-(0)-|   (active, names: '|':UIKeyboardAssistantBar:0x105327350 )>",
    "<NSLayoutConstraint:0x280d86260 'UIButtonBar.maximumAlignmentSize' _UIButtonBarButton:0x10524f2e0.height == UILayoutGuide:0x2817ada40'UIViewLayoutMarginsGuide'.height   (active)>",
    "<NSLayoutConstraint:0x280de1ea0 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x2817ada40'UIViewLayoutMarginsGuide']-(9)-|   (active, names: '|':_UIButtonBarStackView:0x105327c80 )>",
    "<NSLayoutConstraint:0x280de1a40 'UIView-topMargin-guide-constraint' V:|-(10)-[UILayoutGuide:0x2817ada40'UIViewLayoutMarginsGuide']   (active, names: '|':_UIButtonBarStackView:0x105327c80 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x280de1ea0 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x2817ada40'UIViewLayoutMarginsGuide']-(9)-|   (active, names: '|':_UIButtonBarStackView:0x105327c80 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2019-04-02 14:30:15.037632+0100 kiosk[7873:3437019] [LayoutConstraints] 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:0x280db0780 h=--& v=--& UIKeyboardAssistantBar:0x105327350.height == 0   (active)>",
    "<NSLayoutConstraint:0x280df8af0 V:|-(0)-[_UIButtonBarStackView:0x1053281b0]   (active, names: '|':UIKeyboardAssistantBar:0x105327350 )>",
    "<NSLayoutConstraint:0x280df89b0 V:[_UIButtonBarStackView:0x1053281b0]-(0)-|   (active, names: '|':UIKeyboardAssistantBar:0x105327350 )>",
    "<NSLayoutConstraint:0x280d82ad0 'UIButtonBar.maximumAlignmentSize' UIView:0x105505cc0.height == UILayoutGuide:0x2817ad960'UIViewLayoutMarginsGuide'.height   (active)>",
    "<NSLayoutConstraint:0x280de21c0 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x2817ad960'UIViewLayoutMarginsGuide']-(9)-|   (active, names: '|':_UIButtonBarStackView:0x1053281b0 )>",
    "<NSLayoutConstraint:0x280de2120 'UIView-topMargin-guide-constraint' V:|-(10)-[UILayoutGuide:0x2817ad960'UIViewLayoutMarginsGuide']   (active, names: '|':_UIButtonBarStackView:0x1053281b0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x280de21c0 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x2817ad960'UIViewLayoutMarginsGuide']-(9)-|   (active, names: '|':_UIButtonBarStackView:0x1053281b0 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2019-04-02 14:30:15.039691+0100 kiosk[7873:3437019] [LayoutConstraints] 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:0x280db0780 h=--& v=--& UIKeyboardAssistantBar:0x105327350.height == 0   (active)>",
    "<NSLayoutConstraint:0x280df8b40 V:|-(0)-[_UIButtonBarStackView:0x1053286e0]   (active, names: '|':UIKeyboardAssistantBar:0x105327350 )>",
    "<NSLayoutConstraint:0x280df8a00 V:[_UIButtonBarStackView:0x1053286e0]-(0)-|   (active, names: '|':UIKeyboardAssistantBar:0x105327350 )>",
    "<NSLayoutConstraint:0x280d83a70 'UIButtonBar.maximumAlignmentSize' _UIButtonBarButton:0x105352a00.height == UILayoutGuide:0x2817ad880'UIViewLayoutMarginsGuide'.height   (active)>",
    "<NSLayoutConstraint:0x280de24e0 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x2817ad880'UIViewLayoutMarginsGuide']-(9)-|   (active, names: '|':_UIButtonBarStackView:0x1053286e0 )>",
    "<NSLayoutConstraint:0x280de2440 'UIView-topMargin-guide-constraint' V:|-(10)-[UILayoutGuide:0x2817ad880'UIViewLayoutMarginsGuide']   (active, names: '|':_UIButtonBarStackView:0x1053286e0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x280de24e0 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x2817ad880'UIViewLayoutMarginsGuide']-(9)-|   (active, names: '|':_UIButtonBarStackView:0x1053286e0 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2019-04-02 14:30:15.489125+0100 kiosk[7873:3437019] The "OK" alert occured.

Есть объяснение и исправление этой проблемы?

Я использую Swift 4.2.Новое в разработке для iPad.

У меня была похожая проблема с моим UIViewController UITextField, которую я смог исправить, выдав следующий код

extension UIView
{
    func fixInputAssistant()
    {
        for subview in self.subviews
        {
            if type(of: subview) is UITextField.Type
            {
                let item = (subview as! UITextField).inputAssistantItem
                item.leadingBarButtonGroups = []
                item.trailingBarButtonGroups = []
            }
            else if subview.subviews.count > 0
            {
                subview.fixInputAssistant()
            }
        }
    }
}

извнутри функции

override func viewDidLoad() {

        super.viewDidLoad()
        view.fixInputAssistant()
    }

Но я не могу понять, как бы я это сделал с UIAlertController?

...