0

Am trying to show UIKeyboard without using UITextView and UITextField. Am following the below source code to show the Keyboard in my app.

 UIKeyboard *keyboard = [[[UIKeyboard alloc] initWithFrame: CGRectMake(0.0f, 220.0f, 320.0f, 216.0f)] autorelease];
[keyboard setReturnKeyEnabled:NO];
[keyboard setTapDelegate:editingTextView];

but the code showing below errors,

Use of undeclared identifier 'UIKeyboard'
Use of undeclared identifier 'keyboard'

Anyone please help to solve this error? and please tell me this is the right way to show keyboard without using UITextView and UITextField?

Scar
  • 3,460
  • 3
  • 26
  • 51
Gopinath
  • 5,392
  • 21
  • 64
  • 97
  • Because you declared it forcefully. – TheTiger Oct 23 '12 at 10:55
  • @VakulSaini could you please tell me clearly? thanks. – Gopinath Oct 23 '12 at 10:57
  • Was it(UIKeyboard) seen in intelligence ? – TheTiger Oct 23 '12 at 11:02
  • what is the reason to show keyboard, when you dont want user to input anything? – waheeda Oct 23 '12 at 11:03
  • @waheeda please see this question asked by me http://stackoverflow.com/questions/12995514/how-to-keep-keyboard-visible-in-uitextview-non-editable-iphone-app – Gopinath Oct 23 '12 at 11:05
  • @VakulSaini then how can i show keyboard in my app without using UITextView or UITextField? any suggestions please... – Gopinath Oct 23 '12 at 11:06
  • @Gopinath - I gave you answer about your `error` you cant write which is not in intelligence. Have you declared an object of your name in xcode ????? Obviously it will give you an `error`. – TheTiger Oct 23 '12 at 11:08
  • @VakulSaini yes, but when i used Google to show keyboard without UITextView they gave this code so am trying. so if you could you please guide me to do this? Thanks. – Gopinath Oct 23 '12 at 11:12
  • @VakulSaini please see this one. http://stackoverflow.com/questions/13005969/it-is-possible-to-show-keyboard-without-using-uitextfield-and-uitextview-iphone – Gopinath Oct 23 '12 at 11:13

1 Answers1

1

You can use UIKeyInput delegate.

#import <UIKit/UIKit.h>
@interface ViewController : UIViewController<UIKeyInput>

And in your ViewController.m class. return YES; to canBecomeFirstResponder:

-(BOOL)canBecomeFirstResponder
{
    return YES; 
}

It will show you keyboard. But Where you write if there is no UITextView or UITextField. Well for writing on UIView see this logics - UIKeyInput- Displaying keyboard in iPhone without UITextField or UITextView

TheTiger
  • 13,264
  • 3
  • 57
  • 82
  • Thanks a lot friend. Now i can see the keyboard. I won't allow the user to enter any texts. I want to add an UIToolbar in this keyboard as InputAccessoryView. I will try this and let you know friend. – Gopinath Oct 23 '12 at 12:23