【问题标题】:How to remove keyboard bar with buttons Previous and Next and Done on UIWebView? [duplicate]如何在 UIWebView 上使用“上一个”和“下一个”和“完成”按钮删除键盘栏? [复制]
【发布时间】:2012-12-22 04:23:13
【问题描述】:

可能重复:
how to remove prev next button from virtual keyboard IOS

我在我的UIWebView 中打开键盘,但按照UIWebView 的默认结构,我在键盘顶部获得了带有Previous、Next 和Done button 的Bar。

它在我的应用程序中占用了很多空间,所以我想删除那个栏。

我怎样才能删除那个栏?

【问题讨论】:

    标签: iphone objective-c ios uiwebview


    【解决方案1】:
    Register for notification on keyboard showing:
    
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
    Then:
    
    - (void)removeBar
    {
        // Locate non-UIWindow.
        UIWindow *keyboardWindow = nil;
        for (UIWindow *testWindow in [[UIApplication sharedApplication] windows])
        {
            if (![[testWindow class] isEqual:[UIWindow class]])
            {
                keyboardWindow = testWindow;
                break;
            }
        }
    
        // Locate UIWebFormView.
        for (UIView *possibleFormView in [keyboardWindow subviews])
        {
            // iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
            if ([[possibleFormView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound)
            {
                for (UIView *subviewWhichIsPossibleFormView in [possibleFormView subviews])
                {
                    if ([[subviewWhichIsPossibleFormView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound)
                    {
                        [subviewWhichIsPossibleFormView removeFromSuperview];
                    }
                }
            }
            else if ([[possibleFormView description] rangeOfString:@"UIImageView"].location != NSNotFound)
            {
                [possibleFormView removeFromSuperview]; //remove shadow above bar. If it doesn't remove shadow then set possibleFormView's frame as CGRectZero
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2015-01-11
      • 1970-01-01
      • 2011-09-29
      • 2018-06-23
      • 2021-07-14
      • 2019-10-30
      • 2011-12-23
      • 2018-07-22
      相关资源
      最近更新 更多