У меня серьезные проблемы с автоматической компоновкой в iOS 8. Я работаю над пользовательской клавиатурой, но я не могу получить представление для отображения на правильной высоте. Представленный вид на устройстве выходит слишком низко, больше похоже на предполагаемую высоту UIImageView. Я установил ограничения, как показано на рисунке:Невозможно получить ограничения прямо в пользовательской клавиатуре iOS8
Но я получаю эту ошибку в журнале, что ничего мне не говорит (возможно, потому что я не понимаю, где искать):
2014-12-06 19:56:45.095 [40268:12181198] 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:0x600000096940 V:[UIInputView:0x7fe780d3f600(246)]>",
"<NSLayoutConstraint:0x600000097390 'UIView-Encapsulated-Layout-Height' V:[UIInputView:0x7fe780d3f600(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600000096940 V:[UIInputView:0x7fe780d3f600(246)]>
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.
Я пробовал выполнить код в iOS 8 Custom Keyboard: Changing the Height, но он по-прежнему не работает.
Edit:
Я устанавливаю мое ограничение высоты с помощью следующей функции:
override func updateViewConstraints() {
super.updateViewConstraints()
// Add custom view sizing constraints here
let changeToOrientation = deviceInfoService.getOrientationForView(self.inputView)
if (changeToOrientation == Orientation.Portrait) {
self._heightConstraint!.constant = 246
self.inputView.addConstraint(self._heightConstraint!)
} else {
self._heightConstraint!.constant = 192
self.inputView.addConstraint(self._heightConstraint!)
}
}
Не могли бы вы добавить остальную часть журнала? В частности, часть о 'translatesAutoresizingMaskIntoConstraints', которая предшествует. – Rick
С AutoLayout вы вообще не хотите устанавливать '.translatesAutoresizingMaskIntoConstraints = no'? – mc01
Я добавил недостающую часть журнала. – Malakim