Monday, October 15, 2012

Remove UIWebView's key bord top bar.


UIWindow *keyboardWindow = nil;
- (void)removeBar { 
    // Locate UIWebFormView.
    for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
        if (![[testWindow class] isEqual:[UIWindow class]]) {
            keyboardWindow = testWindow;
            // 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]) {
                        NSRange range = [[subviewWhichIsPossibleFormView description] rangeOfString:@"UIWebFormAccessory"];
                        if (range.location != NSNotFound) {
                            [subviewWhichIsPossibleFormView removeFromSuperview]; 
                        }
                    }
                }
            } 
        }
    }   
}

No comments:

Post a Comment