keyboardcontroller监控器键盘怎么使用
答案:2 悬赏:60 手机版
解决时间 2021-11-23 04:55
- 提问者网友:低吟詩仙的傷
- 2021-11-22 11:03
keyboardcontroller监控器键盘怎么使用
最佳答案
- 五星知识达人网友:过活
- 2021-11-22 12:40
KeyboardController用于简化iOS的键盘处理。
用法:
To use KeyboardController, simply initialize it with an array of UITextField objects.
id textFields = @[_textField1, _textField2,
_textField3, _textField4, _textField5];
self.keyboardController = [KeyboardController controllerWithTextFields:textFields];
KeyboardController, depending on a returnKeyType property of an UITextField instance, will:
UIReturnKeyNext - move to next text field
UIReturnKeyDone - close keyboard
You can interact with KeyboardController directly via the following methods:
- (void)moveToNextTextField;
- (void)moveToPreviousTextField;
- (void)closeKeyboard;
KeyboardControllerDelegate
You could also take advantage of delegation methods:
- (void)controllerDidHideKeyboard:(KeyboardController *)controller;
- (void)controllerDidShowKeyboard:(KeyboardController *)controller;
- (void)controllerWillHideKeyboard:(KeyboardController *)controller;
- (void)controllerWillShowKeyboard:(KeyboardController *)controller;
by setting a delegate property of a KeyboardController:
self.keyboardController.delegate = self;
UITextFieldDelegate
There is also an option of setting a textFieldDelegate property of all textFields that are under control of KeyboardController:
self.keyboardController.textFieldDelegate = self;
This could be particulary useful if you would like to add individual behaviour to UITextFields objects.
- (void)textFieldDidBeginEditing:(UITextField *)textField {
if (textField == self.textField4) [self _moveViewByY:-50];
if (textField == self.textField5) [self _moveViewByY:-200];
}
- (void)textFieldDidEndEditing:(UITextField *)textField {
if (textField == self.textField4) [self _moveViewByY:50];
if (textField == self.textField5) [self _moveViewByY:200];
}
用法:
To use KeyboardController, simply initialize it with an array of UITextField objects.
id textFields = @[_textField1, _textField2,
_textField3, _textField4, _textField5];
self.keyboardController = [KeyboardController controllerWithTextFields:textFields];
KeyboardController, depending on a returnKeyType property of an UITextField instance, will:
UIReturnKeyNext - move to next text field
UIReturnKeyDone - close keyboard
You can interact with KeyboardController directly via the following methods:
- (void)moveToNextTextField;
- (void)moveToPreviousTextField;
- (void)closeKeyboard;
KeyboardControllerDelegate
You could also take advantage of delegation methods:
- (void)controllerDidHideKeyboard:(KeyboardController *)controller;
- (void)controllerDidShowKeyboard:(KeyboardController *)controller;
- (void)controllerWillHideKeyboard:(KeyboardController *)controller;
- (void)controllerWillShowKeyboard:(KeyboardController *)controller;
by setting a delegate property of a KeyboardController:
self.keyboardController.delegate = self;
UITextFieldDelegate
There is also an option of setting a textFieldDelegate property of all textFields that are under control of KeyboardController:
self.keyboardController.textFieldDelegate = self;
This could be particulary useful if you would like to add individual behaviour to UITextFields objects.
- (void)textFieldDidBeginEditing:(UITextField *)textField {
if (textField == self.textField4) [self _moveViewByY:-50];
if (textField == self.textField5) [self _moveViewByY:-200];
}
- (void)textFieldDidEndEditing:(UITextField *)textField {
if (textField == self.textField4) [self _moveViewByY:50];
if (textField == self.textField5) [self _moveViewByY:200];
}
全部回答
- 1楼网友:一袍清酒付
- 2021-11-22 12:50
Keyboard Controller 简介 主板的键盘有一块专用的接口芯片,一般是采用一块单片微处理器8042(现在大多已集成在南桥或SIO里)。它控制整个键盘的工作,包括加电自检、键盘扫描码的缓冲以及与主板的通讯。INT 09H是H/W中断,对应IRQ1,INT 16H是一个S/W中断。当键盘的一个键被按下时,键盘接口芯片根据被按下的位置,INT 09H负责把键值转换成INT16H认识的值,返回给INT 16H。INT 16H再把该值根据OS所选定的不同语系键盘而转换成相应的二进制字符传给OS或应用程序。当用户敲击键盘速度过快,使主CPU来不及处理时,则先将所键入的内容送往住存储器的键盘缓冲区,等CPU能处理时,便从缓冲区中取出,送入CPU进行分析和执行。一般在PC机的内存中安排了大约20个字符的键盘缓冲区。 8042分输入缓冲和输出缓冲,它的数据传输在I/O口60H和64H进行。基本上,I/O 64H是命令和状态口,I/O 60H是数据口,它们同时可做读写动作,在读和写时有着不同的意义。I/O 64H的bit 0、1置位分别代表输出/输入缓冲满。如果发现输入缓冲满(即判断出I/O 64H[1]=1),要从I/O 60H将数据读完。BIOS在自检时如果确定输入/输出缓冲都没有问题,会发“AAH”给I/O 64H,让它自测试。等到输入缓冲空(说明上一个命令已执行完),输出缓冲满(KB控制器对自测试命令有反应),再读I/O 60H是否为“55H”(IBM PC/AT规范)。如果是,则表示KB没有问题,若等不到输出缓冲满,说明有问题。 在写命令之前,必须对I/O 64H口送一个60H的值,并等到输入缓冲空,再操作I/O 60H。同样,在读状态之前,也必须对I/O 64H口送一个20H的值,并等到输出缓冲满(表示有状态输出),再操作I/O 60H。这时,我们可以把64H看作索引口,而60H看作数据口。 键盘接口芯片除了接受来自键盘的信息外,还要负责A20地址线的切换,因为当CPU从实模式切换到保护模式时便是通过A20地址线的切换完成的。平常A20为“0”时,CPU工作于DOS的实模式;当A20切换为“1”时,便可进入保护模式。但由于键盘接口芯片切换A20地址线的速度不够快,目前多由主板上的芯片组以模拟方式取代,这样也就省去了一块键盘接口芯片
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯