iOS 6에서 제한을 사용하려고하고 다른 레이블을 정렬하려고합니다. 하나의 레이블과 구속 조건은 버튼을 탭하여 동적으로 생성됩니다. 이것은 매우 간단한 예이지만 유선 오류가 발생하고 원인을 알 수 없습니다.iOS 6 자동 레이아웃 제약 조건 오류 : "무언가가 없습니다"
코드 :
- (IBAction)addToLog:(UIButton *)sender {
UILabel *labelLastTime = [[UILabel alloc]initWithFrame:CGRectMake(20, 359, 92, 42)];
labelLastTime.text = [NSString stringWithFormat:@"%@kg x %@", self.selectedPickerWeight, self.selectedPickerRepetitions];
labelLastTime.font = [UIFont boldSystemFontOfSize:17.0];
labelLastTime.textAlignment = NSTextAlignmentCenter;
labelLastTime.textColor = [UIColor colorWithRed:133.0/255.0 green:133.0/255.0 blue:133.0/255.0 alpha:1.0];
labelLastTime.backgroundColor = [UIColor colorWithRed:228.0/255.0 green:228.0/255.0 blue:228.0/255.0 alpha:1.0];
labelLastTime.layer.borderColor = [UIColor colorWithRed:185.0/255.0 green:185.0/255.0 blue:185.0/255.0 alpha:1.0].CGColor;
labelLastTime.layer.borderWidth = 1;
labelLastTime.layer.cornerRadius = 5;
[self.view setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view addSubview:labelLastTime];
NSLayoutConstraint *cn = [NSLayoutConstraint constraintWithItem:labelLastTime
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self.labelTodayVsLastTime
attribute:NSLayoutFormatAlignAllBottom
multiplier:1.0
constant:5.0];
[self.view addConstraint:cn];
}
오류 : 응용 프로그램을 종료
인해 캐치되지 않는 예외 'NSInvalidArgumentException'에 이유 : 'descriptionForLayoutAttribute_layoutItem_coefficient에 대한 설명을 만들 수 없습니다. 무언가가 없습니다 '
내가 설정했을 때가 아니라 제약을 적용 할 때 오류가 발생합니다. 나는 약간 다른 제한 조건 정의와 같은 문제를 겪고 난 그냥
[self.view addConstraint:cn]
전에 중단 점을 설정하고 난 결과를 검사 할 때, 내가이 4
container, markerAndPositiveExtraVar, negativeExtraVar and _flange
self.labelTodayVsLastTime이 유효한지 확인 했습니까? 나는 두 번째 속성이 coefficent라고 생각한다. – Padin215