2017-11-04 13 views
5

पॉप करता है जब WKWebView में कोई इनपुट केंद्रित हो जाता है तो बाधाओं में त्रुटि आती है।WKWebView समस्या तब होती है जब कीबोर्ड

कोड:

class ViewController: UIViewController { 
    override func viewDidLoad() { 
     super.viewDidLoad(); 
     let wv = WKWebView(frame: CGRect(x: 100, y: 100, width: 100, height: 100)); 
     wv.loadHTMLString("<input type='text'/>", baseURL: nil); // it also can be select, it makes no difference 
     view.addSubview(wv); 
    } 
} 

त्रुटि लॉग:

2017-11-05 00:26:28.861439+0700 achievator[20048:75393577] [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:0x60c0000955e0 h=-&- v=-&- UIToolbar:0x7f8540419570.width == 
_UIInputViewContent:0x7f8540411830.width (active)>", 
    "<NSAutoresizingMaskLayoutConstraint:0x60c000095720 h=--& v=--& _UIInputViewContent:0x7f8540411830.width == 0 (active)>", 
    "<NSLayoutConstraint:0x60800009a9a0 H:|-(0)-[_UIButtonBarStackView:0x7f854041b2d0] (active, names: '|':_UIToolbarContentView:0x7f8540402de0)>", 
    "<NSLayoutConstraint:0x60800009a9f0 _UIButtonBarStackView:0x7f854041b2d0.trailing == _UIToolbarContentView:0x7f8540402de0.trailing + 8 (active)>", 
    "<NSLayoutConstraint:0x608000099a00 _UIToolbarContentView:0x7f8540402de0.trailing == UIToolbar:0x7f8540419570.trailing (active)>", 
    "<NSLayoutConstraint:0x608000099aa0 H:|-(0)-[_UIToolbarContentView:0x7f8540402de0] (active, names: '|':UIToolbar:0x7f8540419570)>", 
    "<NSLayoutConstraint:0x6040000981a0 H:|-(0)-[_UIModernBarButton:0x7f854050ef70] (active, names: '|':_UIButtonBarButton:0x7f854050e7f0)>", 
    "<NSLayoutConstraint:0x6040000981f0 H:[_UIModernBarButton:0x7f854050ef70]-(>=8)-| (active, names: '|':_UIButtonBarButton:0x7f854050e7f0)>", 
    "<NSLayoutConstraint:0x6040000999b0 H:|-(8)-[_UIModernBarButton:0x7f8540512450'Done'] (active, names: '|':_UIButtonBarButton:0x7f8540511660)>", 
    "<NSLayoutConstraint:0x604000099a00 H:[_UIModernBarButton:0x7f8540512450'Done']-(0)-| (active, names: '|':_UIButtonBarButton:0x7f8540511660)>", 
    "<NSLayoutConstraint:0x60c000094690 'UISV-canvas-connection' UILayoutGuide:0x6080001a9a00'UIViewLayoutMarginsGuide'.leading == 
_UIButtonBarButton:0x7f854050e7f0.leading (active)>", 
    "<NSLayoutConstraint:0x60c0000946e0 'UISV-canvas-connection' UILayoutGuide:0x6080001a9a00'UIViewLayoutMarginsGuide'.trailing == 
_UIButtonBarButton:0x7f8540511660.trailing (active)>", 
    "<NSLayoutConstraint:0x60c000094780 'UISV-spacing' H:[_UIButtonBarButton:0x7f854050e7f0]-(0)-[UIView:0x7f854050f4c0] (active)>", 
    "<NSLayoutConstraint:0x60c000094960 'UISV-spacing' H:[UIView:0x7f854050f4c0]-(0)-[_UIButtonBarButton:0x7f854050ea30] (active)>", 
    "<NSLayoutConstraint:0x60c000094a00 'UISV-spacing' H:[_UIButtonBarButton:0x7f854050ea30]-(0)-[UIView:0x7f8540511480] (active)>", 
    "<NSLayoutConstraint:0x60c000094a50 'UISV-spacing' H:[UIView:0x7f8540511480]-(0)-[_UIButtonBarButton:0x7f8540511660] (active)>", 
    "<NSLayoutConstraint:0x60800009a6d0 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x6080001a9a00'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UIButtonBarStackView:0x7f854041b2d0)>", 
    "<NSLayoutConstraint:0x60800009a770 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x6080001a9a00'UIViewLayoutMarginsGuide']-(0)-|(LTR) (active, names: '|':_UIButtonBarStackView:0x7f854041b2d0)>") 

Will attempt to recover by breaking constraint <NSLayoutConstraint:0x6040000981f0 H:[_UIModernBarButton:0x7f854050ef70]-(>=8)-| (active, names: '|':_UIButtonBarButton:0x7f854050e7f0)> 

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. 2017-11-05 00:26:28.863156+0700 achievator[20048:75393577] [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:0x60c0000955e0 h=-&- v=-&- UIToolbar:0x7f8540419570.width == 
_UIInputViewContent:0x7f8540411830.width (active)>", 
    "<NSAutoresizingMaskLayoutConstraint:0x60c000095720 h=--& v=--& _UIInputViewContent:0x7f8540411830.width == 0 (active)>", 
    "<NSLayoutConstraint:0x60800009a9a0 H:|-(0)-[_UIButtonBarStackView:0x7f854041b2d0] (active, names: '|':_UIToolbarContentView:0x7f8540402de0)>", 
    "<NSLayoutConstraint:0x60800009a9f0 _UIButtonBarStackView:0x7f854041b2d0.trailing == _UIToolbarContentView:0x7f8540402de0.trailing + 8 (active)>", 
    "<NSLayoutConstraint:0x608000099a00 _UIToolbarContentView:0x7f8540402de0.trailing == UIToolbar:0x7f8540419570.trailing (active)>", 
    "<NSLayoutConstraint:0x608000099aa0 H:|-(0)-[_UIToolbarContentView:0x7f8540402de0] (active, names: '|':UIToolbar:0x7f8540419570)>", 
    "<NSLayoutConstraint:0x604000098560 H:|-(>=5)-[_UIModernBarButton:0x7f8540510b40] (active, names: '|':_UIButtonBarButton:0x7f854050ea30)>", 
    "<NSLayoutConstraint:0x604000098650 H:[_UIModernBarButton:0x7f8540510b40]-(>=5)-| (active, names: '|':_UIButtonBarButton:0x7f854050ea30)>", 
    "<NSLayoutConstraint:0x6040000999b0 H:|-(8)-[_UIModernBarButton:0x7f8540512450'Done'] (active, names: '|':_UIButtonBarButton:0x7f8540511660)>", 
    "<NSLayoutConstraint:0x604000099a00 H:[_UIModernBarButton:0x7f8540512450'Done']-(0)-| (active, names: '|':_UIButtonBarButton:0x7f8540511660)>", 
    "<NSLayoutConstraint:0x60c000094690 'UISV-canvas-connection' UILayoutGuide:0x6080001a9a00'UIViewLayoutMarginsGuide'.leading == 
_UIButtonBarButton:0x7f854050e7f0.leading (active)>", 
    "<NSLayoutConstraint:0x60c0000946e0 'UISV-canvas-connection' UILayoutGuide:0x6080001a9a00'UIViewLayoutMarginsGuide'.trailing == 
_UIButtonBarButton:0x7f8540511660.trailing (active)>", 
    "<NSLayoutConstraint:0x60c000094780 'UISV-spacing' H:[_UIButtonBarButton:0x7f854050e7f0]-(0)-[UIView:0x7f854050f4c0] (active)>", 
    "<NSLayoutConstraint:0x60c000094960 'UISV-spacing' H:[UIView:0x7f854050f4c0]-(0)-[_UIButtonBarButton:0x7f854050ea30] (active)>", 
    "<NSLayoutConstraint:0x60c000094a00 'UISV-spacing' H:[_UIButtonBarButton:0x7f854050ea30]-(0)-[UIView:0x7f8540511480] (active)>", 
    "<NSLayoutConstraint:0x60c000094a50 'UISV-spacing' H:[UIView:0x7f8540511480]-(0)-[_UIButtonBarButton:0x7f8540511660] (active)>", 
    "<NSLayoutConstraint:0x60800009a6d0 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x6080001a9a00'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UIButtonBarStackView:0x7f854041b2d0)>", 
    "<NSLayoutConstraint:0x60800009a770 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x6080001a9a00'UIViewLayoutMarginsGuide']-(0)-|(LTR) (active, names: '|':_UIButtonBarStackView:0x7f854041b2d0)>") 

Will attempt to recover by breaking constraint <NSLayoutConstraint:0x604000098650 H:[_UIModernBarButton:0x7f8540510b40]-(>=5)-| (active, names: '|':_UIButtonBarButton:0x7f854050ea30)> 

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. 

उत्तर

4

मेरी धारणा आईओएस 11 में यह एक बग है। शिकायत कीबोर्ड के लिए बटन बार में घटकों के बारे में है जो सभी ओएस द्वारा निर्धारित डिफ़ॉल्ट मानों का उपयोग कर रहे हैं। मैंने आईओएस 9 और आईओएस 10 दोनों पर एक ही कोड चलाया है और कोई त्रुटि संदेश नहीं मिला है।

1

एक या अधिक की कमी एक ही समय जब कीबोर्ड खुला है पर संगत नहीं हैं।

हाथ से फ्रेम करने के बजाय, WKWebView में बाधाओं को सेट करने का प्रयास करें।

private func addWKWebView(){ 
    let wv = WKWebView() 
    view.addSubview(wv); 
    wv.translatesAutoresizingMaskIntoConstraints = false 


    wv.widthAnchor.constraint(equalTo: view.widthAnchor ).isActive = true 
    wv.heightAnchor.constraint(equalTo: view.heightAnchor).isActive = true 
    wv.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true 
    wv.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true 
} 

या कुछ इस तरह:

private func addWKWebView(){ 
    let wv = WKWebView() 
    view.addSubview(wv); 
    wv.translatesAutoresizingMaskIntoConstraints = false 


    wv.widthAnchor.constraint(equalToConstant: 100).isActive = true 
    wv.heightAnchor.constraint(equalToConstant: 100).isActive = true 
    wv.widthAnchor.constraint(equalToConstant: 100).isActive = true 
    wv.heightAnchor.constraint(equalToConstant: 100).isActive = true 
} 

यू WkWebView जहां यू चाहते हैं निर्धारित करने के लिए अपने बाधाओं के साथ चारों ओर खेलने के लिए की जरूरत है।

+0

दोनों ने कोशिश की, न तो मदद की। दोनों मामलों में त्रुटि अभी भी पॉप अप है। – mnemon1ck

+0

फिर आप अन्य बाधाओं हो सकते हैं। आप स्टोरीबोर्ड में WKWebView क्यों नहीं जोड़ते हैं ताकि आप वास्तविक समय में देख सकें चुड़ैल बाधाएं शिकायत कर रही हैं। – alegelos

+0

इसके अलावा यू उनमें से 4 को कम प्राथमिकता जोड़ने की कोशिश कर सकते हैं: जाने चौड़ाई = wv.widthAnchor.constraint (equalToConstant: 100) width.isActive = सच width.priority = .defaultLow – alegelos

संबंधित मुद्दे