在uikeyboard顶部添加工具栏 [英] Adding tool bar on top of the uikeyboard
本文介绍了在uikeyboard顶部添加工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个工具栏,我想把它放在键盘的顶部。
在keyboardwillshow通知,我试图添加工具栏到键盘,但没有运气,我不能添加
请让我知道
UIWindow * tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView * keyboard;
for(int i = 0; i <[tempWindow.subviews count]; i ++)
{
//获取当前视图的引用
keyboard = [tempWindow。 subviews objectAtIndex:i];
//检查我们引用的视图的描述是否是UIKeyboard,如果是这样,那么我们找到
//键盘视图,我们正在寻找
if ([[keyboard description] hasPrefix:@< UIKeyboard] == YES)
{
[keyboard addSubview:myToolbar];
}
}
解决方案
I认为,您需要一个 inputAccessoryView 。 / p>
基本上,您创建一个视图,并将其设置为文本字段或文本视图的输入附件视图。
[textField setInputAccessoryView:inputAccessoryView];
I have a toolbar and i would like to place it on top of the keyboard.
In the keyboardwillshow notification, i tried to add toolbar to the keyboard but no luck, i cant add
Please let me know
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];
}
}
解决方案
I think, you want an inputAccessoryView.
Basically, you create a view and set it as a text field's or text view's input accessory view.
[textField setInputAccessoryView:inputAccessoryView];
这篇关于在uikeyboard顶部添加工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文