0

重複の可能性:
仮想キーボードIOSから前の次のボタンを削除する方法

私は自分でキーボードを開いてUIWebViewいますが、デフォルトの構造に従って、キーボードの上部にUIWebView前、次、完了のバーを取得しています。button

アプリで多くのスペースを消費するので、そのバーを削除したいと思います。

どうすればそのバーを削除できますか?

4

1 に答える 1

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
        }
    }
}
于 2013-01-08T10:43:39.893 に答える