Я новичок в автомаркете. Я выполнил весь свой проект из xib-файла, но теперь у меня возникла проблема, когда я должен программно обновлять высоту представления. Я пробовал ниже, но теперь работаю.Программно программируется ограничение по высоте
[[self view] addConstraint:[NSLayoutConstraint constraintWithItem:loginContainer attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0f constant:loginFrame.size.height]];
В консоли это показывает
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:0x78724530 V:[UIView:0x790cdfb0(170)]>",
"<NSLayoutConstraint:0x787da210 V:[UIView:0x790cdfb0(400)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x78724530 V:[UIView:0x790cdfb0(170)]>
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.
Вместо добавления совершенно новое ограничение, то почему бы не просто обновите существующий? Создайте IBOutlet для существующего ограничения и измените значение 'constant'. –
Вы должны сделать IBOutlet для ограничения высоты, которое вы сделали в IB, и изменить его свойство 'constant' в коде. – rdelmar
этот 'loginContainer' является подзором представления, которое загружается из' [NSBundle mainBundle] loadNibName: 'как я могу создать IBOutlet здесь? –