views:

81

answers:

3

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.

+1  A: 

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
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]) ?
Sijo
A: 

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;
}
Boom
+1  A: 

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];      
                        }
                    }
Sijo
instead of using hasPrefix to determine if an instance if of a particular class, use `isMemberOfClass:` or `isKindOfClass:`
Jasarien