iOS开发中监听键盘状态、输入法状态
2015-05-28 14:14
483 查看
#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //监听键盘状态 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil]; //监听输入法状态 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeInputMode:) name:UITextInputCurrentInputModeDidChangeNotification object:nil]; } #pragma mark Notification //keyBoard已经展示出来 - (void)keyboardDidShow:(NSNotification *)notification { NSValue* aValue = [[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey]; CGRect keyboardRect = [aValue CGRectValue]; CGRect keyboardFrame = [self.view convertRect:keyboardRect fromView:[[UIApplication sharedApplication] keyWindow]]; CGFloat keyboardHeight = keyboardFrame.size.height; NSLog(@"##keboardHeight=%.2f",keyboardHeight); } //输入法发生切换 -(void)changeInputMode:(NSNotification *)notification{ NSString *inputMethod = [[UITextInputMode currentInputMode] primaryLanguage]; NSLog(@"inputMethod=%@",inputMethod); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end 来源 : http://www.lvtao.net/ios/522.html
相关文章推荐
- iPhone开发【二十八】监听键盘状态、输入法状态
- iOS移动开发中监听键盘移动的事件,自动调整view-(1)-UIKeyboardFrameEndUserInfoKey
- IOS开发键盘上方的view随着键盘的弹出、收起、键盘输入法改变而移动
- iOS - 开发中监听系统键盘删除按钮 , 回车按钮小技巧
- IOS开发-网络监听以及网络状态更改
- iOS开发之-------监听textview编辑状态
- iOS开发——监听耳机状态(是否插入)
- ios开发之--键盘的监听
- ios 动态监听键盘输入法和高度
- IOS开发 实现电话呼叫功能以及监听电话状态
- iOS开发之-------监听textfield编辑状态
- iOS开发之监听键盘高度的变化
- ios开发之--通过通知监听textfield的输入状态,判断按钮的状态
- ios-day08-01(模仿QQ聊天界面。ios通知的使用(对键盘状态的监听)、枚举和分类的使用、拉伸图片、计算文本字符串的尺寸
- ios 开发在应用中监听(判断)来电状态-接听-拒接-CoreTelephony
- iOS开发之监听键盘高度的变化 分类: ios技术 2015-04-21 12:04 233人阅读 评论(0) 收藏
- iOS开发之监听键盘高度的变化
- iOS笔记监听键盘状态 获取键盘高度
- ios 动态监听键盘输入法和高度
- iOS开发中实时监听app的网络连接状态问题