簡體   English   中英

約束問題

[英]Constraints issue

我的約束有問題。 任何想法,將不勝感激!!

我嘗試使用調試器在 UIViewAlertForUnsatisfiableConstraints 創建一個符號斷點來捕獲它,但我不知道如何解決這個問題。

這是代碼:

func makeFullScreen(){
        sceneView.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            sceneView.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 0),
            sceneView.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: 0),
            sceneView.leftAnchor.constraint(equalTo: self.view.leftAnchor, constant: 0),
            sceneView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: 0),
        ])
    }

這是錯誤:

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. 
(
    "<NSLayoutConstraint:0x28234ff70 ARSCNView:0x11a450d60.bottom == UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide'.bottom   (active)>",
    "<NSLayoutConstraint:0x28234fd90 ARSCNView:0x11a450d60.top == UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide'.top   (active)>",
    "<NSLayoutConstraint:0x28234f7f0 ARSCNView:0x11a450d60.centerY == UIView:0x117daeeb0.centerY   (active)>",
    "<NSLayoutConstraint:0x28234fe80 'UIViewSafeAreaLayoutGuide-bottom' V:[UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide']-(34)-|   (active, names: '|':UIView:0x117daeeb0 )>",
    "<NSLayoutConstraint:0x28234fe30 'UIViewSafeAreaLayoutGuide-top' V:|-(44)-[UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide']   (active, names: '|':UIView:0x117daeeb0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x28234f7f0 ARSCNView:0x11a450d60.centerY == UIView:0x117daeeb0.centerY   (active)>

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.
2020-06-23 20:15:25.809104+0100 App[3611:633364] [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. 
(
    "<NSLayoutConstraint:0x28234ff70 ARSCNView:0x11a450d60.bottom == UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide'.bottom   (active)>",
    "<NSLayoutConstraint:0x28234fd90 ARSCNView:0x11a450d60.top == UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide'.top   (active)>",
    "<NSLayoutConstraint:0x28234f610 ARSCNView:0x11a450d60.height == UIView:0x117daeeb0.height   (active)>",
    "<NSLayoutConstraint:0x28234fe80 'UIViewSafeAreaLayoutGuide-bottom' V:[UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide']-(34)-|   (active, names: '|':UIView:0x117daeeb0 )>",
    "<NSLayoutConstraint:0x28234fe30 'UIViewSafeAreaLayoutGuide-top' V:|-(44)-[UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide']   (active, names: '|':UIView:0x117daeeb0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x28234ff70 ARSCNView:0x11a450d60.bottom == UILayoutGuide:0x283932f40'UIViewSafeAreaLayoutGuide'.bottom   (active)>

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.

錯誤信息很清楚。 您不能設置頂部和底部centerY-and-height。 這是一個過度決定。 選擇頂部和底部centerY-and-height。

問自己 centerY/height 約束來自哪里很有趣,因為它們不在您顯示的代碼中,所以我不知道那個問題的答案。 其他地方必須有更多代碼。 也許這些是您之前設置的約束? 如果是這樣,您將必須立即刪除它們。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM