에 XB에서 contentContainer
이라는 제약 조건을 추가하려고합니다. 나는 Auto Layout에 친환경적이지만, 새로운 iPhone으로 인해 나를 강제하게되었습니다. 죄송합니다,하지만 난 contentContainer
내자동 레이아웃을 사용하여 UIView를 숨길 때 프로그래밍 방식으로 제약 조건 추가
이 fixedContentContainer
라는 UIView
입니다 ... 10 평판을 가지고, 그래서 나를 이렇게이 설명이 더 복잡해질 것 XIB의 사진을 게시하지 않습니다 스택하지 않습니다. 그 컨테이너는 그 안에있는 모든 UIViews
높이의 관점에서 매번 동일합니다. IB의 컨테이너 내용에 제약 조건을 추가했습니다. 모든 것이 잘 작동합니다.
- 정적
UILabel
UITableView
eventDescriptionHeaderLabel
- 동적
UILabel
라는tableView
는 - 정적
UILabel
라고 불리는eventDescriptionLabel
friendsLabel
라고 :
contentContainer
에서 또한
fixedContentContainer
아래 4 명
UIView
목적은
내가 성취하려는 것은 간단합니다. 사용자가 일정을 열고 친구가없는 경우 friendsLabel
및 tableView
을 입력 한 다음 eventDescriptionHeaderLabel
및 eventDescriptionLabel
을 빈 공간을 채우기 위해 위로 이동합니다. 당분간, 나는 다만 간단하게 시작하고 싶다. 난 단지 VB에서 추가 할 수있는 friendsLabel
에 제약 조건을 프로그래밍 방식으로 추가하려고 시도 했으므로 분명히 잘못된 것이 있습니다. (모든 코드가 작동하면 나머지 코드는 업로드하게되어 기쁩니다.)
NSDictionary *viewsDictionary = @{@"fixedContentContainer":self.fixedContentContainer,
@"friendsLabel":self.friendsLabel,
@"tableView":self.tableView,
@"eventDescriptionHeaderLabel":self.eventDescriptionHeaderLabel,
@"eventDescriptionLabel":self.eventDescriptionLabel};
// Add 8px of space between bottom of fixedContentContainer and top of friendsLabel
[self.contentContainer addConstraints:
[NSLayoutConstraint constraintsWithVisualFormat:@"V:[fixedContentContainer]-8-[friendsLabel]"
options:0
metrics:nil
views:viewsDictionary]];
// Add 15px to the left and 10px to the right of padding between friendsLabel and superview (contentContainer)
[self.contentContainer addConstraints:
[NSLayoutConstraint constraintsWithVisualFormat:@"|-15-[friendsLabel]-10-|"
options:0
metrics:nil
views:viewsDictionary]];
// Set height for friendsLabel at 21px
[self.contentContainer addConstraints:
[NSLayoutConstraint constraintsWithVisualFormat:@"V:[friendsLabel(21)]"
options:0
metrics:nil
views:viewsDictionary]];
그냥 보조 노트로, 직접 containerView
에 UILabel
또는 정지에 높이 제약 조건을 추가 : 나는 프로그래밍 방식으로 제약 조건을 추가 할 경우 여기에
이야? 여기에 내가 콘솔에서 얻고 무엇을 (내가 IB를 통해 정확한 몇 가지 제약 조건을 추가하면 난 아무것도하지 않음) :
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:0x84cafae0 EBWebImageView:0x84cafa40.width == 1.78448*EBWebImageView:0x84cafa40.height>",
"<NSLayoutConstraint:0x84cb04a0 V:[UILabel:0x84cb03a0'Kimberly Otte | Jenna Lau...'(26)]>",
"<NSLayoutConstraint:0x84cb0c50 V:[UIImageView:0x84cb0ba0(20)]>",
"<NSLayoutConstraint:0x84cb0f40 V:[UIImageView:0x84cb0e20(20)]>",
"<NSLayoutConstraint:0x84cb16b0 V:[UILabel:0x84cb1540'Event Details'(21)]>",
"<NSLayoutConstraint:0x84cb19a0 V:[UITableView:0x7c361e00(225)]>",
"<NSLayoutConstraint:0x84cb2fc0 H:[EBWebImageView:0x84cafa40]-(0)-| (Names: '|':UIView:0x84caf9a0)>",
"<NSLayoutConstraint:0x84cb2ff0 H:|-(0)-[EBWebImageView:0x84cafa40] (Names: '|':UIView:0x84caf9a0)>",
"<NSLayoutConstraint:0x84cb3020 V:|-(0)-[EBWebImageView:0x84cafa40] (Names: '|':UIView:0x84caf9a0)>",
"<NSLayoutConstraint:0x84cb30e0 V:[EBWebImageView:0x84cafa40]-(0)-[UILabel:0x84cb03a0'Kimberly Otte | Jenna Lau...']>",
"<NSLayoutConstraint:0x84cb3170 V:[UILabel:0x84cb03a0'Kimberly Otte | Jenna Lau...']-(8)-[UIImageView:0x84cb0ba0]>",
"<NSLayoutConstraint:0x84cb3260 V:[UIImageView:0x84cb0ba0]-(8)-[UIImageView:0x84cb0e20]>",
"<NSLayoutConstraint:0x84cb33b0 V:[UIImageView:0x84cb0e20]-(8)-[UILabel:0x84cb1540'Event Details']>",
"<NSLayoutConstraint:0x84cb34a0 V:[UILabel:0x84cb1540'Event Details']-(5)-[UITableView:0x7c361e00]>",
"<NSLayoutConstraint:0x84cb34d0 V:[UITableView:0x7c361e00]-(0)-| (Names: '|':UIView:0x84caf9a0)>",
"<NSLayoutConstraint:0x84cb54e0 H:[UIView:0x84caf9a0]-(0)-| (Names: '|':UIView:0x84caf900)>",
"<NSLayoutConstraint:0x84cb5510 V:|-(0)-[UIView:0x84caf9a0] (Names: '|':UIView:0x84caf900)>",
"<NSLayoutConstraint:0x84cb5540 H:|-(0)-[UIView:0x84caf9a0] (Names: '|':UIView:0x84caf900)>",
"<NSIBPrototypingLayoutConstraint:0x84cb55a0 'IB auto generated at build time for view with fixed frame' V:|-(581)-[UILabel:0x84cb37e0'Friends'] (Names: '|':UIView:0x84caf900)>",
"<NSLayoutConstraint:0x84cb6c20 V:[UIView:0x84caf9a0]-(8)-[UILabel:0x84cb37e0'Friends']>",
"<NSLayoutConstraint:0x7fc3cb90 'UIView-Encapsulated-Layout-Width' H:[UIScrollView:0x860ed080(320)]>",
"<NSAutoresizingMaskLayoutConstraint:0x7d237f80 h=-&- v=-&- UIView:0x84caf900.width == UIScrollView:0x860ed080.width>"
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x84cb19a0 V:[UITableView:0x7c361e00(225)]>
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.
다른 건 필요하고 도움을 주셔서 감사되면 알려 주시기 바랍니다.