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'

有人请帮忙解决这个错误吗?请告诉我这是在不使用UITextViewand的情况下显示键盘的正确方法UITextField

4

1 回答 1

1

您可以使用UIKeyInput委托。

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

在你的ViewController.m课堂上。return YES;canBecomeFirstResponder:

-(BOOL)canBecomeFirstResponder
{
    return YES; 
}

它会告诉你keyboard。但是如果没有UITextView或,你在哪里写UITextField。写得好,UIView看看这个逻辑 - UIKeyInput- 在没有 UITextField 或 UITextView 的 iPhone 中显示键盘

于 2012-10-23T11:30:22.723 回答