Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone Swift-自定义键盘高度_Iphone_Swift_Ios8 - Fatal编程技术网

Iphone Swift-自定义键盘高度

Iphone Swift-自定义键盘高度,iphone,swift,ios8,Iphone,Swift,Ios8,我用xib文件创建了一个自定义键盘。它工作得很好,我想显示,但我在调试键盘时收到很多警告。。我在xib中创建了所有约束,并将其作为子视图添加到我的视图中 var nib = UINib(nibName: "Keyboard", bundle: nil) let objects = nib.instantiateWithOwner(self, options: nil) mainView = objects.first as UIView view.addSubview(mainView) 我在

我用xib文件创建了一个自定义键盘。它工作得很好,我想显示,但我在调试键盘时收到很多警告。。我在xib中创建了所有约束,并将其作为子视图添加到我的视图中

var nib = UINib(nibName: "Keyboard", bundle: nil)
let objects = nib.instantiateWithOwner(self, options: nil)
mainView = objects.first as UIView
view.addSubview(mainView)
我在viewDidLoad()方法中执行此操作。在ViewDidDisplay()中,我调用此函数来获取我的身高:

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.
2014-09-17 12:21:21.689 Hodor[6629:1086407]无法同时满足约束条件。
可能下面列表中至少有一个约束是您不想要的。试着这样做:(1)看看每个约束,试着找出你不期望的约束;(2) 找到添加了不需要的约束的代码,然后修复它。(注意:如果您看到不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性TranslatesAutoResizingMaskToConstraints的文档)
(
"",
""
)
将尝试通过打破约束进行恢复
在UIViewAlertForUnsatifiableConstraints处创建一个符号断点,以便在调试器中捕获该断点。
中列出的UIView上UIConstraintBasedLayoutDebugging类别中的方法也可能会有所帮助。
2014-09-17 12:21:21.693 Hodor[6629:1086407]无法同时满足约束条件。
可能下面列表中至少有一个约束是您不想要的。试着这样做:(1)看看每个约束,试着找出你不期望的约束;(2) 找到添加了不需要的约束的代码,然后修复它。(注意:如果您看到不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性TranslatesAutoResizingMaskToConstraints的文档)
(
"",
""
)
将尝试通过打破约束进行恢复
在UIViewAlertForUnsatifiableConstraints处创建一个符号断点,以便在调试器中捕获该断点。
中列出的UIView上UIConstraintBasedLayoutDebugging类别中的方法也可能会有所帮助。
2014-09-17 12:21:21.697 Hodor[6629:1086407]无法同时满足约束条件。
可能下面列表中至少有一个约束是您不想要的。试着这样做:(1)看看每个约束,试着找出你不期望的约束;(2) 找到添加了不需要的约束的代码,然后修复它。(注意:如果您看到不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性TranslatesAutoResizingMaskToConstraints的文档)
(
"",
""
)
将尝试通过打破约束进行恢复
在UIViewAlertForUnsatifiableConstraints处创建一个符号断点,以便在调试器中捕获该断点。
中列出的UIView上UIConstraintBasedLayoutDebugging类别中的方法也可能会有所帮助。

这是什么意思?从警告的文本来看,似乎与高度限制有关…

与限制存在一些冲突。自动调整大小与已应用的约束冲突

与约束存在一些冲突。自动调整大小与已应用的约束冲突

与约束存在一些冲突。自动调整大小与已应用的约束冲突

与约束存在一些冲突。自动调整大小与已应用的约束冲突

试试这个

view.setTranslatesAutoResizengMaskintoConstraints(false) view.addConstraint(NSLayoutConstraint( 项目:主视图,属性:。左侧, relatedBy:。相等,toItem:view, 属性:nslayouttribute.Left,乘数:0.6,常数:0)

试试这个

view.setTranslatesAutoResizengMaskintoConstraints(false) view.addConstraint(NSLayoutConstraint( 项目:主视图,属性:。左侧, relatedBy:。相等,toItem:view, 属性:nslayouttribute.Left,乘数:0.6,常数:0)

试试这个

view.setTranslatesAutoResizengMaskintoConstraints(false) view.addConstraint(NSLayoutConstraint( 项目:主视图,属性:。左侧, relatedBy:。相等,toItem:view, 属性:nslayouttribute.Left,乘数:0.6,常数:0)

试试这个

view.setTranslatesAutoResizengMaskintoConstraints(false) view.addConstraint(NSLayoutConstraint( 项目:主视图,属性:。左侧, relatedBy:。相等,toItem:view, 属性:nslayouttribute.Left,乘数:0.6,常数:0)


你能从XIB发布你的约束和布局的截图吗?看起来有一个约束使键盘的显式高度为180点。但是,似乎包含superview的另一个约束(从距离到顶部+从距离到底部,等等)正试图将其设置为264。有分析这些错误经验的人可能能够缩小范围。因此,以下是布局:我所做的限制:-下一个按钮位于左下角,大小固定为60x60-左按钮位于右上角,有一个固定的宽度60和相同的高度作为向下按钮-向下按钮是在右下角,也有一个固定宽度为60,并具有相同的高度与左按钮-大按钮在中间,如果固定到左边,右边,上部和按钮框架的距离为0。xib中的视图本身为320x180,键盘的高度应为180…请查看@skyline75489中的[接受答案][1]。它起作用了![1] :您能否从XIB发布约束和布局的屏幕截图?看起来有一个约束使键盘的显式高度为180点。但是,似乎包含superview的另一个约束(从距离到顶部+从距离到底部,等等)正试图将其设置为264。有经验分析这些错误的人可能能够缩小范围。因此,以下是布局:我所做的限制:-下一步按钮位于
    view.addConstraint(NSLayoutConstraint(
        item:mainView, attribute:.Right,
        relatedBy:.Equal, toItem:view,
        attribute:.RightMargin,multiplier:0.6, constant: 0))

    view.addConstraint(NSLayoutConstraint(
        item:mainView, attribute:.Width,
        relatedBy:.Equal, toItem:view,
        attribute: .Width,multiplier:0.6, constant: 0))

    view.addConstraint(NSLayoutConstraint(
        item:mainView, attribute:.Height,
        relatedBy:.Equal, toItem:view,
        attribute:.Height,multiplier:0.6, constant: 0))