gpt4 book ai didi

objective-c - 在 uikeyboard 顶部添加工具栏

转载 作者:IT王子 更新时间:2023-10-29 08:13:02 26 4
gpt4 key购买 nike

我有一个工具栏,我想将它放在键盘的顶部。

在 keyboardwillshow 通知中,我尝试将工具栏添加到键盘,但没有成功,我无法添加

请告诉我

UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i = 0; i < [tempWindow.subviews count]; i++)
{
//Get a reference of the current view
keyboard = [tempWindow.subviews objectAtIndex:i];

//Check to see if the description of the view we have referenced is "UIKeyboard" if so then we found
//the keyboard view that we were looking for
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
{
[keyboard addSubview:myToolbar];
}
}

最佳答案

我想,你想要一个 inputAccessoryView .

基本上,您创建一个 View 并将其设置为文本字段或 TextView 的输入辅助 View 。

[textField setInputAccessoryView:inputAccessoryView];

关于objective-c - 在 uikeyboard 顶部添加工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8998134/

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