1

How to set Custom keyboard specific to only a UITextField? When I am changing using this method, all the keyboards in my application are changed to this new custom keyboard. I added:

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

in a UIViewController. But after going to that UIView, keyboards in other UIViewControllers also look like new custom keyboard. How can i limit the custom keyboard to only one UIView? Please help me. Thanks in advance.

Tyler A.
  • 3,048
  • 1
  • 23
  • 27
S.P.
  • 5,427
  • 11
  • 56
  • 83

4 Answers4

4
UITextField* textField;
UIView* customKeyboard;


textField.inputView = customKeyboard;

Similar thread: iPad custom Keyboard GUI

Community
  • 1
  • 1
Tyler A.
  • 3,048
  • 1
  • 23
  • 27
1

If you subclassed UITextView (as that tutorial shows), then all instances of that subclass will use the toolbar with a dismiss button.

If you don't want the toolbar, then don't use the subclass, just use the original UITextView.

Jasarien
  • 58,279
  • 31
  • 157
  • 188
  • I am not subclassing UItextview. I used only that function keyboardWillShow and addObserver method .Is it because i am using for(UIWindow *keyboardWindow in [[UIApplication sharedApplication] windows]) ? – S.P. Jul 16 '10 at 13:44
1

You can try checking for the textfield that you want on the textFieldShouldBeginEditing like so:

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    if (textField == YOUR_DESIRED_TEXTFIELD) {
        [self openCustomKeyboard];
    }
    return YES;
}
iDevZilla
  • 61
  • 5
1

My problem was once am loading custom keyboard, it remains everywhere in other UIviews of application. So i checked existence of UIToolbar in other UIkeyboard subviews and removed . Now its working fine..

    for(UIView* keyboardToolbar in [keyboard subviews]){
        if([[keyboardToolbar description] hasPrefix:@"<UIToolbar"] == YES)
            {
                [keyboardToolbar removeFromSuperview];      
            }
    }
Tyler A.
  • 3,048
  • 1
  • 23
  • 27
S.P.
  • 5,427
  • 11
  • 56
  • 83
  • 1
    instead of using hasPrefix to determine if an instance if of a particular class, use `isMemberOfClass:` or `isKindOfClass:` – Jasarien Jul 19 '10 at 14:51