How to find UIWebView toolbar (to replace them) on iOS 6?

后端 未结 1 1038
情话喂你
情话喂你 2020-12-18 15:06

I have tried the following code from another application but it doesn\'t find anything. Why? How to get access to the UIWebView toolbar?

- (UITo         


        
相关标签:
1条回答
  • 2020-12-18 15:48

    With the following code you should be able to remove the toolbar that is above the keyboard.

    -(void)viewWillAppear:(BOOL)animated{
      [[NSNotificationCenter defaultCenter] addObserver:self
                                            selector:@selector(keyboardWillShow:)
                                                name:UIKeyboardWillShowNotification
                                              object:nil];
    }
    
    - (void)keyboardWillShow:(NSNotification *)note {
      [self performSelector:@selector(removeBar) withObject:nil afterDelay:0];
    }
    - (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 *formView in [keyboardWindow subviews]) {
      // iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
      if ([[formView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) {
        for (UIView *subView in [formView subviews]) {
            if ([[subView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound) {
                // remove the input accessory view
                [subView removeFromSuperview];
            }
            else if([[subView description] rangeOfString:@"UIImageView"].location != NSNotFound){
                // remove the line above the input accessory view (changing the frame)
                [subView setFrame:CGRectZero];
            }
        }
      }
    }
    }
    
    0 讨论(0)
提交回复
热议问题