如何删除键盘栏上的按钮上一页和下一页以及在UIWebView上完成?

时间:2013-01-08 10:28:21

标签: iphone objective-c ios uiwebview

  

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

我正在UIWebView打开键盘,但根据UIWebView的默认结构,我在键盘顶部显示上一个,下一个和完成button的条形码。

它在我的应用程序中消耗了很多空间,所以,我想删除该栏。

如何删除该栏?

1 个答案:

答案 0 :(得分:0)

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
        }
    }
}