2

I have a UITextView that is being edited and I want to add a custom keyboard... is there any way to dismiss the keyboard but leave the textView in edit mode so the blue cursor keeps flashing? Or better yet is there any way to put a view ontop of the keyboard?

Albert Renshaw
  • 17,282
  • 18
  • 107
  • 195
  • 1
    RohinNZ's anser to http://stackoverflow.com/questions/5615806/disable-uitextfield-keyboard should be helpful here. – Ephemera Jan 17 '13 at 05:05
  • Works great! Thankyou very much! I didn't realize at firs that if the keyboard is already up you have to dismiss it, assign the dummy view and then bring back the keyboard (which won't display this time but will bring the cursor back) – Albert Renshaw Jan 17 '13 at 05:11
  • Here's a copy of his code in-case it gets deleted. `UIView* dummyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];` `myTextField.inputView = dummyView;` – Albert Renshaw Jan 17 '13 at 05:11

2 Answers2

2

You should register for notification UIKeyboardWillShowNotification. It will hit the registered function before displaying keyboard.

Here you can iterate through all Windows and can identify keyboard by below way:

for (UIWindow *keyboardWindow in [[UIApplication sharedApplication] windows]) 
{
    for (UIView *keyboard in [keyboardWindow subviews]) 
    {
        if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES
           ||[[keyboard description] hasPrefix:@"<UIPeripheralHost"]== YES) 

        {
                  //Set proper frame to hide key board here..
       }

}

Apurv
  • 17,116
  • 8
  • 51
  • 67
-2

try this

uitextfieldView.inputView = [[UIView new] autorelease];

the system keyboard view not shows and it keeps the cursor as you editing.

or you can hide keyboard by sliding it off-screen

frame.origin.y = (keyboard.frame.origin.y - 264);
keyboard.frame = frame;
Ravindra Bagale
  • 17,226
  • 9
  • 43
  • 70
  • The first line of code didn't work, as for the second line of code where did you declare the variable "keyboard"? – Albert Renshaw Jan 17 '13 at 05:01
  • It worked now! I didn't realize that I had to dismiss the keyboard then assign the inputView then bring back the keyboard for that code to work! Thanks! – Albert Renshaw Jan 17 '13 at 05:13