2013-08-06 6 views
1

J'ai un fichier html affiché par mon UIWebView dans mon ensemble de projets. Je veux cacher le clavier d'IOS et montrer mon propre clavier virtuel (écrit dans Jquery) en éditant une entrée dans UIWebView. Est-il possible de masquer le clavier lors de la modification du contenu dans UIWebView? Je ne peux pas utiliser la méthode blur() pour un élément car je veux modifier le contenu. Je dois le faire sans clavier ios?Masquer le clavier lors de la modification du contenu UIWebView

SOLUTION

J'ai trouvé la solution.

- (void)viewDidLoad 
{ 
    NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; 
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]]; 
    self.webView.delegate=self; 

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

    [super viewDidLoad]; 

} 
- (void)esconde { 
    for (UIWindow *keyboardWindow in [[UIApplication sharedApplication] 
windows]) 
     for (UIView *keyboard in [keyboardWindow subviews]) 
      if([[keyboard description] hasPrefix:@"<UIPeripheralHostView"] 
== YES)        [keyboard removeFromSuperview]; 
} 
- (void)keyboardWillShow:(NSNotification *)aNotification { 
[self performSelector:@selector(esconde) withObject:nil afterDelay:0]; 
} 
+0

Si vous avez trouvé la réponse, postez-la en guise de réponse, puis acceptez-la pour que les autres utilisateurs n'essaient pas de vous aider à trouver une solution lorsque vous n'en avez pas besoin. Il aidera également les autres en montrant que vous avez trouvé une solution au problème qu'ils pourraient avoir. – CaptJak

+0

Je reçois un avertissement "vous ne pouvez pas accepter votre réponse dans deux jours" – amone

Répondre

1

SOLUTION

J'ai trouvé la solution.

- (void)viewDidLoad 
{ 
    NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; 
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]]; 
    self.webView.delegate=self; 

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

    [super viewDidLoad]; 

} 
- (void)esconde { 
    for (UIWindow *keyboardWindow in [[UIApplication sharedApplication] 
windows]) 
     for (UIView *keyboard in [keyboardWindow subviews]) 
      if([[keyboard description] hasPrefix:@"<UIPeripheralHostView"] 
== YES)        [keyboard removeFromSuperview]; 
} 
- (void)keyboardWillShow:(NSNotification *)aNotification { 
[self performSelector:@selector(esconde) withObject:nil afterDelay:0]; 
} 
Questions connexes