如何在iOS8自定义键盘上面添加工具栏?

时间:2022-02-20 07:11:28

My problem is write picture. I really need you help. Maybe inputAccessoryView, inputAccessoryViwController can be used, but I really have no idea. Thanks so much! 如何在iOS8自定义键盘上面添加工具栏?

我的问题是写图片。我真的需要你的帮助。也许inputAccessoryView,inputAccessoryViwController可以使用,但我真的不知道。非常感谢!

1 个解决方案

#1


0  

You can adjust the height of your custom keyboard’s primary view using Auto Layout. By default, a custom keyboard is sized to match the system keyboard, according to screen size and device orientation. A custom keyboard’s width is always set by the system to equal the current screen width. To adjust a custom keyboard’s height, change its primary view's height constraint.

您可以使用“自动布局”调整自定义键盘主视图的高度。默认情况下,根据屏幕大小和设备方向,自定义键盘的大小可与系统键盘匹配。系统始终将自定义键盘的宽度设置为等于当前屏幕宽度。要调整自定义键盘的高度,请更改其主视图的高度约束。

The following code lines show how you might define and add such a 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];

Source: https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/Keyboard.html

Add the code to viewDidAppear/viewWillAppear

将代码添加到viewDidAppear / viewWillAppear

Add your bar to the extra space. You can not make the background transparent.

将您的酒吧添加到额外的空间。您无法使背景透明。

#1


0  

You can adjust the height of your custom keyboard’s primary view using Auto Layout. By default, a custom keyboard is sized to match the system keyboard, according to screen size and device orientation. A custom keyboard’s width is always set by the system to equal the current screen width. To adjust a custom keyboard’s height, change its primary view's height constraint.

您可以使用“自动布局”调整自定义键盘主视图的高度。默认情况下,根据屏幕大小和设备方向,自定义键盘的大小可与系统键盘匹配。系统始终将自定义键盘的宽度设置为等于当前屏幕宽度。要调整自定义键盘的高度,请更改其主视图的高度约束。

The following code lines show how you might define and add such a 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];

Source: https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/Keyboard.html

Add the code to viewDidAppear/viewWillAppear

将代码添加到viewDidAppear / viewWillAppear

Add your bar to the extra space. You can not make the background transparent.

将您的酒吧添加到额外的空间。您无法使背景透明。