UITextField根据Keyboard自动移动
来源:互联网 发布:java三大框架学习顺序 编辑:程序博客网 时间:2024/06/08 16:51
1.注册通知
- (void)viewDidLoad{ [super viewDidLoad]; // Do any additional setup after loading the view from its nib. // 键盘高度变化通知,ios5.0新增的#ifdef __IPHONE_5_0 float version = [[[UIDevice currentDevice] systemVersion] floatValue]; if (version >= 5.0) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:)name:UIKeyboardWillChangeFrameNotification object:nil]; }#endif }
2.
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ self.bzView.frame = CGRectMake(0, self.view.bounds.size.height-216-44, 320, 44); return YES;}- (BOOL)textFieldShouldReturn:(UITextField *)textField{ [textField resignFirstResponder]; self.bzView.frame = CGRectMake(0, self.view.bounds.size.height-44, 320, 44); return YES;}#pragma mark -键盘弹出时调用的方法#pragma mark Responding to keyboard events- (void)keyboardWillShow:(NSNotification*)notification { NSDictionary *userInfo = [notification userInfo]; // Get the origin of the keyboard when it's displayed. NSValue* aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey]; CGRect keyboardRect = [aValue CGRectValue]; self.bzView.frame = CGRectMake(0, self.view.bounds.size.height-keyboardRect.size.height-44, 320, 44); }-(void)dealloc{ [[NSNotificationCenter defaultCenter] removeObserver:self];//在视图控制器消除时,移除键盘事件的通知 }
0 0
- UITextField根据Keyboard自动移动
- Keyboard 遮挡 UITextField
- 如何解决Keyboard 遮挡 UITextField的问题?
- UITextField 与 keyboard (软键盘)
- IOS9 IPAD UITextField hide keyboard shortcut bar.!
- ios uitextfield uialertview keyboard奇怪的问题
- UITextField跟随键盘移动
- 移动端根据屏幕大小自动设置body字体大小
- iOS UITextField自动换行
- android keyboard 跳转自动出现
- Hide or remove keyboard When Click UITextField(UITextView)
- 【转载】Keyboard挡住了待输入的UITextField的解决办法
- How to make UITextField move up when keyboard is present
- UITextField移动光标到最后
- UITextField手机号中间自动空格
- Keyboard
- keyboard
- Keyboard
- 《大话重构》
- 在Phonegap下实现oAuth认证
- 断言(assert宏)的副作用
- ASP .net 实现文件上传 下载功能
- 你叹这一生太漫长 却不知我愿用所有与你交换
- UITextField根据Keyboard自动移动
- qt object and thread/signal and slots
- C#执行DOS命令,返回DOS命令的输出
- Logging 日志记录最佳实践
- JQuery when
- 单例模式C++实现
- tomcat中自定义docBase
- vb.net限制文本框只能输入数字
- apache frpserver工程复用(一) 用户列表获取