【问题标题】:Why iPhone X InputViewController height is like half of system keyboard size?为什么 iPhone X UIInputViewController 高度是系统键盘大小的一半?
【发布时间】:2017-12-06 14:31:04
【问题描述】:

我正在 iPhone X 中测试自定义键盘扩展。我刚刚创建了一个带有键盘扩展的新项目。正如您在 2 张照片中看到的,自定义键盘的高度只有系统键盘高度的一半。我不知道为什么。有什么办法可以像系统键盘高度一样获得实际的键盘高度?

Custom Keyboard

iOS System Keyboard

【问题讨论】:

  • 问题解决了吗?
  • 运气好能解决这个问题吗?
  • 这正是我遇到的问题。通过为自定义输入视图设置自动调整掩码的 .flexibleHeight 选项,就像文档所说的那样,这不适用于任何具有主页指示器的手机。我也需要帮助解决这个问题:(
  • @Miki 请试试这个。我认为您需要将锚点设置为键盘视图。添加此代码。 [self.yourKeyboard.leftAnchor constraintEqualToAnchor:self.view.leftAnchor].active = YES; [self.yourKeyboard.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor].active = YES;
  • 您好,感谢您的评论,但我已经尝试过,得到了相同的结果,但没有运气。也许我的代码中还有其他问题,现在,作为一种解决方法,我使用的是固定高度

标签: ios11 iphone-x ios-keyboard-extension


【解决方案1】:

给你。将这段代码写在viewDidAppear

CGFloat _expandedHeight = 500; //The height you want
NSLayoutConstraint *_heightConstraint = 
    [NSLayoutConstraint constraintWithItem: self.view 
                                 attribute: NSLayoutAttributeHeight 
                                 relatedBy: NSLayoutRelationEqual 
                                    toItem: nil 
                                 attribute: NSLayoutAttributeNotAnAttribute 
                                multiplier: 0.0 
                                  constant: _expandedHeight];
[self.view addConstraint: _heightConstraint];

在 iOS 8.0 中,您可以在主视图最初在屏幕上绘制后随时调整自定义键盘的高度。

【讨论】:

    猜你喜欢
    • 2019-08-23
    • 2018-03-07
    • 2019-05-23
    • 2015-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-02
    • 1970-01-01
    相关资源
    最近更新 更多