iphone keyboard
来源:互联网 发布:蜘蛛数据平台 编辑:程序博客网 时间:2024/06/01 08:40
1.在视图控制器中声明UITextField变量
#import <UIKit/UIKit.h>//#import <UIKeyboard.h>//#import <AppKit/NSEvent.h>@interface keyboardViewController : UIViewController <UITextFieldDelegate> { IBOutlet UITextField *txt; }@property (nonatomic,retain) UITextField *txt;@end
2.打开viewDidLoad注释,加入如下代码:
- (void)viewDidLoad{ [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyPressed:) name: UITextFieldTextDidChangeNotification object: nil]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyPressed:) name: UITextViewTextDidChangeNotification object: nil]; //We set the delegate so we can grab keypressed txt=[[UITextField alloc] initWithFrame:CGRectZero]; txt.returnKeyType= UIReturnKeyDone; txt.delegate = self; [self.view addSubview:txt]; [txt becomeFirstResponder]; //Show the keyboard [super viewDidLoad];}
3.键盘响应函数
- (void)keyPressed:(NSNotification*)notification{ NSLog(@"hello"); // NSLog([[notification object] text]); NSString *str= [[NSString alloc] init]; str=[[notification object] text]; const char *cstring=[str UTF8String]; NSLog(@"%s",cstring);}
- iphone keyboard
- iPhone dismiss keyboard
- Keyboard
- keyboard
- Keyboard
- keyboard
- keyBoard
- keyboard
- keyboard
- KeyBoard
- keyboard
- keyboard
- keyboard iPhone-Portrait-NumberPad; using 563160167_Portrait_iPhone-Simple-Pad_Default
- iphone-使用TextField及关闭键盘(useing TextField for inputs、using the keyboard)
- Can’t find keyplane that supports type 4 for keyboard iPhone-Portrait-NumberPad
- Can't find keyplane that supports type 4 for keyboard iPhone-Portrait-NumberPad; using 3876877096_Po
- Can't find keyplane that supports type 4 for keyboard iPhone-PortraitChoco-NumberPad;
- Can't find keyplane that supports type 4 for keyboard iPhone-PortraitChoco-NumberPad; using 27057872
- 使用 /proc 文件系统来访问 Linux 内核的内容
- 设计师眼中的HTML5
- 世纪佳缘 小秘书 (可自动吸引异性关注)
- linux内核空间与用户空间信息交互方法
- 防止SQL注入漏洞
- iphone keyboard
- 相同的函数调用的问题
- Linux给网卡设置VLAN
- hdu 2571
- 使用GDI+ 保存HDC为位图文件
- c#多线程技术专题
- Struts2 标签自定义格式显示数值、日期
- hdu 2845
- 刚发现的恋爱宝典