0

UITextViewandを使用せずに UIKeyboard を表示しようとしていUITextFieldます。私のアプリでキーボードを表示するために、以下のソースコードに従っています。

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

しかし、以下のエラーを示すコード、

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

誰でもこのエラーを解決するのを手伝ってくれますか? UITextViewUITextField?を使用せずにキーボードを表示する正しい方法を教えてください。

4

1 に答える 1

1

UIKeyInputデリゲートを使用できます。

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

そしてあなたのViewController.mクラスで。return YES;canBecomeFirstResponder:

-(BOOL)canBecomeFirstResponder
{
    return YES; 
}

それはあなたを示しますkeyboard。ただし、 または がない場合はどこに書くUITextViewUITextField。このロジックをUIView参照してください - UIKeyInput- Displaying keyboard in iPhone without UITextField or UITextView

于 2012-10-23T11:30:22.723 に答える