【问题标题】:Turn OFF Split Keyboard programmatically [duplicate]以编程方式关闭拆分键盘[重复]
【发布时间】:2013-03-20 18:27:47
【问题描述】:

有没有办法以编程方式关闭键盘拆分。

【问题讨论】:

  • 键盘滚动是什么意思?
  • 我已经编辑了我的问题。请再次检查

标签: iphone objective-c keyboard


【解决方案1】:

据我所知,您无法锁定默认的 iPad 键盘滚动动作。

您可以管理它的其他功能,例如键盘类型,也可以创建自定义 uikeyboard。

请查看this post 正在讨论创建自定义uikeyboard

但是,请查看此代码并尝试实现您的目标

    //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 className] isEqualToString:@\"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...
        }
    }

【讨论】:

    猜你喜欢
    • 2011-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-15
    • 2022-12-06
    相关资源
    最近更新 更多