5

時々、次のようなエラーが発生し続けます-TextViewまたはButtonが意味するヒントなしで:

    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) 
(
    "<NSLayoutConstraint:0x11d748d0 V:[UITextView:0xc1bb000(65)]>",
    "<NSLayoutConstraint:0x11d77620 V:[UIButton:0x11d71cf0(44)]>",
    "<NSLayoutConstraint:0x11d7be30 V:[UIButton:0x11d79e70(43)]>",
    "<NSLayoutConstraint:0xa1980d0 V:|-(134)-[UITextView:0xc1bb000]   (Names: '|':UIView:0xa1afba0 )>",
    "<NSLayoutConstraint:0xa199ed0 UITextView:0xc1bb000.centerY == UIButton:0x11d71cf0.centerY>",
    "<NSLayoutConstraint:0xa199e50 V:[UIButton:0x11d79e70]-(61)-[UIButton:0x11d71cf0]>",
    "<NSLayoutConstraint:0xa199cb0 V:|-(40)-[UIButton:0x11d79e70]   (Names: '|':UIView:0xa1afba0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x11d748d0 V:[UITextView:0xc1bb000(65)]>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

クラッシュの原因となっているコード内の制約を特定する方法はありますか?

テキスト:

  Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x11d748d0 V:[UITextView:0xc1bb000(65)]>

残念ながら、これがコードにどの制約があるのか​​ わからないため、あまり役に立ちません

4

1 に答える 1

7

次のように読みます。

<NSLayoutConstraint:0x11d748d0 V:    [UITextView:0xc1bb000(65)]>
 ^ Constraint type  ^ Address  ^Axis ^Description in VFL
                      (of constraint)

したがって、これはテキストビューの高さを 65 ポイントにする制約です。そこには、このテキスト ビューをスーパービューの上端から 134 ポイントに固定する制約もあります。

<NSLayoutConstraint:0xa1980d0 V:|-(134)-[UITextView:0xc1bb000]   (Names: '|':UIView:0xa1afba0 )>

そして、テキスト ビューの Y 中心をボタンの Y 中心に固定する制約:

<NSLayoutConstraint:0xa199ed0 UITextView:0xc1bb000.centerY == UIButton:0x11d71cf0.centerY>

そして、ボタン自体を特定の垂直位置に固定する制約:

<NSLayoutConstraint:0xa199e50 V:[UIButton:0x11d79e70]-(61)-[UIButton:0x11d71cf0]>

これらすべての制約が必要なわけではない可能性があります。ここでは、テキスト ビューを垂直方向に配置しようとする 2 つの制約があります (ボタンに基づいて、スーパービューの上部からの絶対間隔に基づいて)。

アプリのどこかに、テキスト フィールドと 2 つのボタンを含むビューが必要です。すべての例外を中断する場合は、ログに記載されているさまざまなアドレスからログアウトして、わからない場合はスーパービューなどを見つけることができますが、うまくいけば、これから解決できると思います.

場合によっては、ログをテキスト エディターにコピーし、アドレスを見つけて単語に置き換えると読みやすくなります。

于 2013-04-08T09:15:22.207 に答える