gpt4 book ai didi

iphone - iOS 8 自定义键盘高度从纵向更改,然后更改为横向,然后再更改为纵向

转载 作者:行者123 更新时间:2023-12-03 19:07:44 24 4
gpt4 key购买 nike

我们可以在 viewdidload 中创建自定义键盘,如以下代码所示,如​​苹果开发者网站所示。

self.nextKeyboardButton = [UIButton buttonWithType:UIButtonTypeSystem];

[self.nextKeyboardButton setTitle:NSLocalizedString(@"Next Keyboard", @"Title for 'Next Keyboard' button") forState:UIControlStateNormal];
[self.nextKeyboardButton sizeToFit];
self.nextKeyboardButton.translatesAutoresizingMaskIntoConstraints = NO;

[self.nextKeyboardButton addTarget:self action:@selector(advanceToNextInputMode) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:self.nextKeyboardButton];

NSLayoutConstraint *nextKeyboardButtonLeftSideConstraint = [NSLayoutConstraint constraintWithItem:self.nextKeyboardButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0];
NSLayoutConstraint *nextKeyboardButtonBottomConstraint = [NSLayoutConstraint constraintWithItem:self.nextKeyboardButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0];
[self.view addConstraints:@[nextKeyboardButtonLeftSideConstraint, nextKeyboardButtonBottomConstraint]];

但是,有 1 个问题。当我们纵向运行该程序时,自定义键盘的高度约为220。然后我们更改为横向。它小于220。奇怪的是,当我回到纵向 View 时,高度不再是220,它与横向高度相同。它永远不会回到原来的高度。那么,有没有办法改变我们将添加 subview 的 View 高度?

最佳答案

这可能是苹果键盘约束问题的一个错误,旋转时我在日志中看到这些消息:

 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:0xfd04d80 V:[_UIKBCompatInputView:0xf97a580(216)]>",
"<NSLayoutConstraint:0xe325bf0 V:[_UIKBCompatInputView:0xf97a580(162)]>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0xfd04d80 V:[_UIKBCompatInputView:0xf97a580(216)]>

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.

我已经提交了一个错误。

关于iphone - iOS 8 自定义键盘高度从纵向更改,然后更改为横向,然后再更改为纵向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24097664/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com