ios - 自定义键盘高度大于默认键盘

标签 ios iphone xcode custom-keyboard

如何像 gBoard 在他们的键盘中所做的那样自定义键盘大小(参见屏幕截图)。
这里的搜索部分显示在键盘上方。我想在我的应用程序中做同样的事情。有没有人可以帮助我知道使用哪种方法来创建这样的 View 。

enter image description here

最佳答案

你应该看看 inputAccessoryView属性(property)。因为它是 UIResponder 上的属性,可在 UITextView , UITextField和别的。将您的自定义 View 分配给 inputAccessoryView只要您分配给它的 UI 对象具有焦点,它就会出现在键盘顶部。

// Create your custom keyboard accessory view first
// then assign it
yourTextField.inputAccessoryView = yourCustomAccessoryView;

// Bring up keyboard and your accessory view
[yourTextField becomeFirstResponder];

在这里阅读更多
https://developer.apple.com/library/content/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/InputViews/InputViews.html

inputAccessoryView
Assigning a view to this property causes that view to be displayed above the standard system keyboard (or above the custom input view if one is provided) when the text view becomes the first responder. For example, you could use this property to attach a custom toolbar to the keyboard.

关于ios - 自定义键盘高度大于默认键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48802380/

相关文章:

ios - VoiceOver 辅助功能 accessibilityHint 未公布

iphone - UITableView 动画的回调

iPhone 应用程序在设备上崩溃,但在模拟器上则不然。使用 UIWebView 访问本地文件,可能的 [NSBundle mainBundle] 问题?

ios - 单击按钮时 Swift "unrecognized selector sent to instance"

ios - 在 iOS 上的 View 之间转换期间闪烁( ionic 框架)

ios - 无法以编程方式在 Swift 中创建 UIViewController

ios - 试图理解 RNCryptor

iphone - 如何更改 UILabel 中的截断字符?

xcode - 委托(delegate)返回 nil

xcode - 添加 pod 文件并推送。如何撤消?如何在 Xcode 和 github 中使用 gitignore?