How to set Custom keyboard specific to only a UItextfield
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 UIViewController
s also look like new custom keyboard. How can i limit the custom keyboard to only one UIView
? Please help me. Thanks in advance.
UITextField* textField;
UIView* customKeyboard;
textField.inputView = customKeyboard;
Similar thread: iPad custom Keyboard GUI
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.
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;
}
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];
}
}
精彩评论