UIStackView의 투르투메 Warning 대응
개요
iOS의 UIStackView를 사용하여 투르투메 (빈 부분을 채우는 레이아웃)를 할 때 발생한 Warning과 그 대응 방법
구현 내용

Storyboard상의 정의는 상기와 같은 형태.
Button2를 hidden 하는 것으로, Button1과 Button3만의 표시에 틈을 붙인다.
Warning
Button2를 hidden한 타이밍에 아래와 같은 warning이 콘솔에 출력되었다.
console[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:0x61000009ae00 UIButton:0x7ff580d07320'Button2'.height == 40 (active)>",
"<NSLayoutConstraint:0x6000000998c0 'UISV-hiding' UIButton:0x7ff580d07320'Button2'.height == 0 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x61000009ae00 UIButton:0x7ff580d07320'Button2'.height == 40 (active)>
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.
원인과 대응방법
[원인]
warning 내용에도 기재되어 있는 대로 Button2에 설정하고 있다 Height=40
제약과, Button2를 Hidden한 것에 의해 Height=0
가 된다고 하는 상태에 모순이 발생하고 있었기 때문에.
[대응 방법]
제약의 모순을 해제하면 된다.
버튼에 설정한 Height=40의 제약의 Priority를 내린다(999등)

결론
꼼꼼한 레이아웃을 작성하고 있을 때 치고, 묘하게 빠져 버렸습니다.
이번에는 Content Hugging Priority
와 Content Compression Resistance Priority
를 사용하지 않았습니다.
이 근처를 제대로 이해하면, 매우 저비용으로 레이아웃 작성이나 변경을 할 수 있게 되네요.
UIStackView를 터치할 때 아래의 기사가 매우 도움이되었습니다. 감사합니다.
StackView를 현명하게 사용해 라쿠친 AutoLayout
Reference
이 문제에 관하여(UIStackView의 투르투메 Warning 대응), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/m_orishi/items/eaecfb51804d62b31dd5
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)

Storyboard상의 정의는 상기와 같은 형태.
Button2를 hidden 하는 것으로, Button1과 Button3만의 표시에 틈을 붙인다.
Warning
Button2를 hidden한 타이밍에 아래와 같은 warning이 콘솔에 출력되었다.
console[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:0x61000009ae00 UIButton:0x7ff580d07320'Button2'.height == 40 (active)>",
"<NSLayoutConstraint:0x6000000998c0 'UISV-hiding' UIButton:0x7ff580d07320'Button2'.height == 0 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x61000009ae00 UIButton:0x7ff580d07320'Button2'.height == 40 (active)>
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.
원인과 대응방법
[원인]
warning 내용에도 기재되어 있는 대로 Button2에 설정하고 있다 Height=40
제약과, Button2를 Hidden한 것에 의해 Height=0
가 된다고 하는 상태에 모순이 발생하고 있었기 때문에.
[대응 방법]
제약의 모순을 해제하면 된다.
버튼에 설정한 Height=40의 제약의 Priority를 내린다(999등)

결론
꼼꼼한 레이아웃을 작성하고 있을 때 치고, 묘하게 빠져 버렸습니다.
이번에는 Content Hugging Priority
와 Content Compression Resistance Priority
를 사용하지 않았습니다.
이 근처를 제대로 이해하면, 매우 저비용으로 레이아웃 작성이나 변경을 할 수 있게 되네요.
UIStackView를 터치할 때 아래의 기사가 매우 도움이되었습니다. 감사합니다.
StackView를 현명하게 사용해 라쿠친 AutoLayout
Reference
이 문제에 관하여(UIStackView의 투르투메 Warning 대응), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/m_orishi/items/eaecfb51804d62b31dd5
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
[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:0x61000009ae00 UIButton:0x7ff580d07320'Button2'.height == 40 (active)>",
"<NSLayoutConstraint:0x6000000998c0 'UISV-hiding' UIButton:0x7ff580d07320'Button2'.height == 0 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x61000009ae00 UIButton:0x7ff580d07320'Button2'.height == 40 (active)>
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.
[원인]
warning 내용에도 기재되어 있는 대로 Button2에 설정하고 있다
Height=40
제약과, Button2를 Hidden한 것에 의해 Height=0
가 된다고 하는 상태에 모순이 발생하고 있었기 때문에.[대응 방법]
제약의 모순을 해제하면 된다.
버튼에 설정한 Height=40의 제약의 Priority를 내린다(999등)

결론
꼼꼼한 레이아웃을 작성하고 있을 때 치고, 묘하게 빠져 버렸습니다.
이번에는 Content Hugging Priority
와 Content Compression Resistance Priority
를 사용하지 않았습니다.
이 근처를 제대로 이해하면, 매우 저비용으로 레이아웃 작성이나 변경을 할 수 있게 되네요.
UIStackView를 터치할 때 아래의 기사가 매우 도움이되었습니다. 감사합니다.
StackView를 현명하게 사용해 라쿠친 AutoLayout
Reference
이 문제에 관하여(UIStackView의 투르투메 Warning 대응), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/m_orishi/items/eaecfb51804d62b31dd5
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Reference
이 문제에 관하여(UIStackView의 투르투메 Warning 대응), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/m_orishi/items/eaecfb51804d62b31dd5텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)