2011-12-12 15 views
6

Ho usato un UIWebview in IOS 5. Provo a impostare contenteditable="true" per rendere modificabile uiwebview.come rimuovere il pulsante prev next dalla tastiera virtuale IOS

La screenshoot della mia app è simile a un'immagine in questo link How do you remove the Next and Prev buttons from virtual keyboard in Sencha Touch/Phonegap application,

enter image description here

il mio problema è che voglio rimuovere questo tasto prev & successivo dalla tastiera, ma non so come. Qualcuno può aiutarmi?

ringraziamento

+0

ho trovato la soluzione per iOS 8. puoi controllarlo qui: iOS 8 - Rimuovi precedente/successivo/Fine barra degli strumenti UIKeyboard all'interno di un UIWebView http://stackoverflow.com/questions/25022089/remove-next-previous-buttons-inputaccessoryview-for-custom-keyboard-in-ios8 – Gaurav

risposta

11

Questa è una risposta vecchia e non è più a lavorare su iOS 9. Per una soluzione aggiornata, vedere la mia risposta here.


Si tratta di un'area grigia, ma sicuramente possibile.

vedere qui: http://ios-blog.co.uk/iphone-development-tutorials/rich-text-editing-a-simple-start-part-1/

Registrati notifica sul mostrando la tastiera:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; 

Poi:

- (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 *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]; 
       } 
      } 
     } 
    } 
} 
+0

ha lasciato un'area vuota in cui si trovava il bar, come lo rimuovi? – jAckOdE

+0

Puoi provare a ridurre il contenutoInset. –

+0

hm, non ho provato a modo tuo, ma ho scoperto che se si imposta la cornice del modulo accessorio su un "rettangolo vuoto" funziona. – jAckOdE

3

rimuovere l'area vuota.

- (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]) { 
     if ([[possibleFormView description] hasPrefix:@"<UIPeripheralHostView"]) { 
      for (UIView* peripheralView in [possibleFormView subviews]) { 

       // hides the backdrop (iOS 7) 
       if ([[peripheralView description] hasPrefix:@"<UIKBInputBackdropView"]) { 
        //skip the keyboard background....hide only the toolbar background 
        if ([peripheralView frame].origin.y == 0){ 
         [[peripheralView layer] setOpacity:0.0]; 
        } 
       } 
       // hides the accessory bar 
       if ([[peripheralView description] hasPrefix:@"<UIWebFormAccessory"]) { 
        // remove the extra scroll space for the form accessory bar 
        UIScrollView *webScroll; 
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) { 
         webScroll = [[self webView] scrollView]; 
        } else { 
         webScroll = [[[self webView] subviews] lastObject]; 
        } 
        CGRect newFrame = webScroll.frame; 
        newFrame.size.height += peripheralView.frame.size.height; 
        webScroll.frame = newFrame; 

        // remove the form accessory bar 
        [peripheralView removeFromSuperview]; 
       } 
       // hides the thin grey line used to adorn the bar (iOS 6) 
       if ([[peripheralView description] hasPrefix:@"<UIImageView"]) { 
        [[peripheralView layer] setOpacity:0.0]; 
       } 
      } 
     } 
    } 
} 
1

ho trovato la soluzione per iOS 8. È possibile controllare qui:

-(void) removeKeyboard { 
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]) { 

    if ([[possibleFormView description] hasPrefix : @"<UIInputSetContainerView"]) { 
     for (UIView* peripheralView in possibleFormView.subviews) { 

      for (UIView* peripheralView_sub in peripheralView.subviews) { 


       // hides the backdrop (iOS 8) 
       if ([[peripheralView_sub description] hasPrefix : @"<UIKBInputBackdropView"] && peripheralView_sub.frame.size.height == 44) { 
        [[peripheralView_sub layer] setOpacity : 0.0]; 

       } 
       // hides the accessory bar 
       if ([[peripheralView_sub description] hasPrefix : @"<UIWebFormAccessory"]) { 


        for (UIView* UIInputViewContent_sub in peripheralView_sub.subviews) { 

         CGRect frame1 = UIInputViewContent_sub.frame; 
         frame1.size.height = 0; 
         peripheralView_sub.frame = frame1; 
         UIInputViewContent_sub.frame = frame1; 
         [[peripheralView_sub layer] setOpacity : 0.0]; 

        } 

        CGRect viewBounds = peripheralView_sub.frame; 
        viewBounds.size.height = 0; 
        peripheralView_sub.frame = viewBounds; 

       } 
      } 

     } 
    } 
} 
} 

Si può cercare di migliorare questo. prova a chiamare questa funzione all'interno del tuo gestore di eventi UIKeyboardDidShowNotification.

Spero che questo aiuti ... Questo è il livello di opinioni accessorio: (UIWebFormAccessory) -> (UIToolbar) -> (UIImageView, UIToolbarButton, UIToolbarButton)

Problemi correlati