【iOS知识学习】_iPhone学习多个UITextField 键盘弹起
2015-09-01 15:23
645 查看
1.textField.delegate = self 和
UITextFieldDelegate 还是要写的
2.代码中的
#define KEYBOARDHEIGHT216.0f//英文键盘的高度
#define DEFAULTHEIGHT100.0f//根据键盘高度
3.code:
#pragma mark - UITextField Delegate
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
CGFloat offset =self.view.frame.size.height
- (textField.frame.origin.y + textField.frame.size.height+KEYBOARDHEIGHT+DEFAULTHEIGHT);
NSLog(@"%f",offset);
if (offset<=0)
{
[UIViewanimateWithDuration:0.3animations:^{
CGRect frame =self.view.frame;
frame.origin.y = offset;
self.view.frame
= frame;
}];
}
returnYES;
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
[UIViewanimateWithDuration:0.3animations:^{
CGRect frame =self.view.frame;
frame.origin.y =0.0;
self.view.frame
= frame;
}];
returnYES;
}
UITextFieldDelegate 还是要写的
2.代码中的
#define KEYBOARDHEIGHT216.0f//英文键盘的高度
#define DEFAULTHEIGHT100.0f//根据键盘高度
3.code:
#pragma mark - UITextField Delegate
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
CGFloat offset =self.view.frame.size.height
- (textField.frame.origin.y + textField.frame.size.height+KEYBOARDHEIGHT+DEFAULTHEIGHT);
NSLog(@"%f",offset);
if (offset<=0)
{
[UIViewanimateWithDuration:0.3animations:^{
CGRect frame =self.view.frame;
frame.origin.y = offset;
self.view.frame
= frame;
}];
}
returnYES;
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
[UIViewanimateWithDuration:0.3animations:^{
CGRect frame =self.view.frame;
frame.origin.y =0.0;
self.view.frame
= frame;
}];
returnYES;
}
相关文章推荐
- [Bluetooth API]使用Irprops库搜索蓝牙设备
- iOS开发 UIScrollView自带的缩放功能(简单的例子)
- div设置contentEditable="true"作为文本编辑器,定位光标解决办法
- UITouch
- Git+gerrit user guide
- [Bluetooth(SDK)]使用WinSock搜索蓝牙设备
- 【LeetCode】225. Implement Stack using Queues
- UIImageView响应点击事件
- 1099. Build A Binary Search Tree (30)
- Warning: The Copy Bundle Resources build phase contains this target's Info.plist file 'Info
- 【LeetCode】232. Implement Queue using Stacks
- phalcon query 如何找bug
- UIView的基本使用
- 跟随鼠标NGUI
- 十六进制的颜色值转成RGB UIColor
- 使用UIView的animation
- UINavigationController 弹出新的UIViewController时,setNavigationBarHidden失效的问题
- ios uitableview 去掉多余的空行
- ios uitableview uitableviewcell 去掉分隔线
- iPad开发,UIPopoverController的使用