세로와 가로로 다른 AutoLayout을 켜려고하면 경고가 나온 이야기
6315 단어 AutoLayoutiOSSwift
갑작스럽지만
한 화면을 AutoLayout으로 만들고 싶다 (어떻게든 말하지 않는다)
세로
수평


사이즈 클래스마다 제약을 붙여 간다
세로 방향의 제약을 붙인다
1
2
3
4





가로 방향의 제약을 붙인다
1
2
3
4





막상 실기 실행!
세로로 해도 옆으로 해도 Storyboard상에서는 경고 나오지 않는다! 이겼어! 실제 기계로 회전! !
[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:0x282ebd270 UIView:0x10160e2d0.top == UILayoutGuide:0x283494700'UIViewSafeAreaLayoutGuide'.top + 340 (active)>",
"<NSLayoutConstraint:0x282ebd2c0 UILayoutGuide:0x283494700'UIViewSafeAreaLayoutGuide'.bottom == UIView:0x10160e2d0.bottom + 350 (active)>",
"<NSLayoutConstraint:0x282e8d040 'UIView-Encapsulated-Layout-Height' UIView:0x10160a450.height == 390 (active)>",
"<NSLayoutConstraint:0x282ebd450 'UIViewSafeAreaLayoutGuide-bottom' V:[UILayoutGuide:0x283494700'UIViewSafeAreaLayoutGuide']-(21)-| (active, names: '|':UIView:0x10160a450 )>",
"<NSLayoutConstraint:0x282ebd4f0 'UIViewSafeAreaLayoutGuide-top' V:|-(0)-[UILayoutGuide:0x283494700'UIViewSafeAreaLayoutGuide'] (active, names: '|':UIView:0x10160a450 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x282ebd2c0 UILayoutGuide:0x283494700'UIViewSafeAreaLayoutGuide'.bottom == UIView:0x10160e2d0.bottom + 350 (active)>
어쨌든
대신 경고문을 읽는다( 이 사이트
다음 제약 조건을 동시에 충족할 수 없습니다.
UIViewのtop
하지만 SafeAreaのtopから+340
SafeAreaのbottom
하지만 UIViewのbottomから+350
UIViewの高さが390
UIViewのbottom
하지만 SafeAreaのbottomから+21
SafeAreaのtop
하지만 Viewのtop
340, 350… 🤔
!! 지웠을 땐…

Vary for Traits를 사용할 때의 주의점
Size inspector에서 확실히 Constant가 수정되었습니다.
before
after


하지만 제약을 더블 클릭해 보면…

350 남아있는 얀케!
나는 다음과 같은 절차로 제약을 받았다.
분명히 Vary for Traits를 사용하는 동안 Size inspector에서 Constant를 편집하면 새 Constant를 생성하는 것 같습니다.
편집하고 있기 때문에 새롭게 생성하는 것은 그만두고 싶은 생각도 합니다만…
Constantを一つにすることで警告は解消されました
그러나 불가해
소개한 적당한 Constant가 남아 있었다는 것을 알았습니다. 그러나 이 제약은 height가 Regular일 때에만 active가 되어야 하고, Regular 때의 Constant는 350이 아니라 0이 되는 것은…
여러가지 시도했지만 왜 다른 Constant가 유효한 제약이 되어 버리는지 알아내지 못했습니다.
만약 「이런 일로는 🤔」라고 가르쳐 주시는 분 있으시면 꼭 잘 부탁드립니다 🥺
Reference
이 문제에 관하여(세로와 가로로 다른 AutoLayout을 켜려고하면 경고가 나온 이야기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/devdazy/items/68c480b96785446430e6텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)