如何在iOS自定义键盘中切换单词选择视图(更改高度)? [英] How to toggle a word selection view (change height) in iOS custom keyboard?

查看:161
本文介绍了如何在iOS自定义键盘中切换单词选择视图(更改高度)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我' d喜欢在iOS 8自定义键盘中添加类似于上面的单词选择视图。


  1. 如何更改键盘视图矩形动态大小?和

  2. 通知活动应用(例如内置消息应用)以相应地重新定位输入栏?

更新:基于!


I'd to like to add a word selection view similar to the above in an iOS 8 custom keyboard.

  1. How can I change the keyboard view rectangle size dynamically? and
  2. notify the active app (such as the built-in Messages app) to reposition the input bar correspondingly?

UPDATE: based on this, the height of keyboard is customisable. How can that be possible?

解决方案

It IS possible to change the size of the keyboard in the current iOS 8

Taken verbatim from the documentation: "In iOS 8.0, you can adjust a custom keyboard’s height any time after its primary view initially draws on screen."

To resize your custom keyboard, add a simple layout constraint.

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

For more information look at Apple's prerelease documentation here!

这篇关于如何在iOS自定义键盘中切换单词选择视图(更改高度)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆