alo*_*wnx 8 keyboard keyboard-events ios
我是Objective-C的新手,我希望限制用户从普通键盘的字母部分切换到数字/标点符号.这就是说,我想禁用键盘上的按钮进行切换.也许我正在使用错误的搜索参数,但我在谷歌上找不到什么,在我的参考书中更少.我如何实际禁用iOS键盘上的按钮?使用字母/数字/标点字符,只需忽略输入的输入字符即可轻松完成,但在键盘部分之间切换的按钮执行操作而不是返回字符.
谢谢您的帮助!
您实际上可以添加和删除默认按钮UIKeyboard
互联网上有一些食谱,如下所示:http://www.iphonedevsdk.com/forum/iphone-sdk-development/6573-howto-customize-uikeyboard.html和这样的:http://www.iphonedevsdk.com/论坛/iphone-sdk-development/6275-add-toolbar-top-keyboard.html
这些帖子向您展示了如何添加按钮,但是可以使用相同的原理来删除按钮。
下面我将向您展示其中一种解决方案的汇编:
//The UIWindow that contains the keyboard view -
//It some situations it will be better to actually
//iterate through each window to figure out where the keyboard is,
// but In my applications case
//I know that the second window has the keyboard so I just reference it directly
//
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows]
// objectAtIndex:1];
//Because we cant get access to the UIKeyboard throught the SDK we will
// just use UIView.
//UIKeyboard is a subclass of UIView anyways
UIView* keyboard;
//Iterate though each view inside of the selected Window
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 className 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 is now a UIView reference to the
// UIKeyboard we want. From here we can add a subview
// to th keyboard like a new button
//Do what ever you want to do to your keyboard here...
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7138 次 |
| 最近记录: |