Я создал пользовательскую клавиатуру с xib-файлом. Он отлично работает и показывается, как я хочу, но при отладке клавиатуры я получаю много предупреждений. Я создал все ограничения в xib и добавил его в качестве подзаголовка для моего представления.Swift - Пользовательская высота клавиатуры
var nib = UINib(nibName: "Keyboard", bundle: nil)
let objects = nib.instantiateWithOwner(self, options: nil)
mainView = objects.first as UIView
view.addSubview(mainView)
Я делаю это в видеDidLoad() - метод. В viewDidAppear() Я называю это, чтобы получить мой рост:
let heightConstraint = NSLayoutConstraint(item: self.view, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 0.0, constant: 180.0)
view.addConstraint(heightConstraint)
mainView.frame = view.bounds
Но теперь я получаю это предупреждение:
2014-09-17 12:21:21.689 Hodor[6629:1086407] 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:0x178087e40 'UIView-Encapsulated-Layout-Height' V:[UIInputView:0x15e607830(264)]>",
"<NSLayoutConstraint:0x1780882f0 V:[UIInputView:0x15e607830(180)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x178087e40 'UIView-Encapsulated-Layout-Height' V:[UIInputView:0x15e607830(264)]>
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.
2014-09-17 12:21:21.693 Hodor[6629:1086407] 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:0x178087e40 'UIView-Encapsulated-Layout-Height' V:[UIInputView:0x15e607830(264)]>",
"<NSLayoutConstraint:0x1780882f0 V:[UIInputView:0x15e607830(180)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x178087e40 'UIView-Encapsulated-Layout-Height' V:[UIInputView:0x15e607830(264)]>
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.
2014-09-17 12:21:21.697 Hodor[6629:1086407] 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:0x178087e40 'UIView-Encapsulated-Layout-Height' V:[UIInputView:0x15e607830(264)]>",
"<NSLayoutConstraint:0x1780882f0 V:[UIInputView:0x15e607830(180)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x178087e40 'UIView-Encapsulated-Layout-Height' V:[UIInputView:0x15e607830(264)]>
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.
Что это значит? Из текста предупреждений кажется что-то с ограничением по высоте ...
Можете ли вы опубликовать скриншот своих ограничений и макета из XIB? Похоже, одно ограничение придало клавиатуре явную высоту 180 точек. Но тогда отдельное ограничение (либо от расстояния до вершины + расстояние до дна, и т. Д.) Того, что кажется содержательным супервидом, пытается установить его на 264. Кто-то, у кого больше опыта, анализирующий эти ошибки, может сузить его , –
Итак, вот макет: https://cloudup.com/crqoINgTXqg Ограничения, которые я сделал: - следующая кнопка находится в левом нижнем углу, а размер зафиксирован на 60x60 - левая кнопка находится в правой верхний угол имеет фиксированную ширину 60 и ту же высоту, что и кнопка вниз - кнопка вниз находится в правом нижнем углу, имеет фиксированную ширину 60 и имеет ту же высоту, что и левая кнопка - большая кнопка в середине, если зафиксировано на левом, правом, верхнем и кнопочном кадре с расстоянием 0 Вид сам по себе составляет 320x180 в xib, а клавиатура должна быть 180 в высоту ... – Ben
Пожалуйста, посмотрите на [принятый ответ] 1] из @ skyline75489. Оно работает! [1]: http://stackoverflow.com/questions/24167909/ios-8-custom-keyboard-changing-the-height/25819565#comment40988935_25819565 – lifjoy