iOS键盘出现时界面跟着往上推
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillHide:) name:UIKeyboardWillHideNotification object:nil]; #pragma mark 键盘即将显示
- (void)keyBoardWillShow:(NSNotification *)note{ CGRect rect = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGFloat ty = rect.size.height;
[UIView animateWithDuration:[note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue] animations:^{
self.view.transform = CGAffineTransformMakeTranslation(0, - ty + 170);
}]; }
#pragma mark 键盘即将退出
- (void)keyBoardWillHide:(NSNotification *)note{ [UIView animateWithDuration:[note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue] animations:^{
self.view.transform = CGAffineTransformIdentity;
}];
} - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
if (![self.remarkTextView isExclusiveTouch]||(![self.remarkTextView isExclusiveTouch])) { [self.remarkTextView resignFirstResponder];
[self.qqTextField resignFirstResponder]; }
} - (BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
} -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{ if([text isEqualToString:@"\n"]){ [textView resignFirstResponder]; return NO;
} return YES;
}
iOS键盘出现时界面跟着往上推的更多相关文章
- 保持iOS上键盘出现时输入框不被覆盖
如果屏幕中的内容项目比较多,键盘就可能覆盖住文本输入框之类的对象.你必须调整你的内容,使得输入框保持可见. 你会想到哪些处理方法呢? 第一种, 临时调整窗口中各个视图的大小,使得键盘从下向上占领的区域 ...
- 如何保持iOS上键盘出现时输入框不被覆盖
在 iOS5 上请求显示键盘时,系统从屏幕底部将键盘滑入上来,位于应用的内容之上. (墙内:http://mikixiyou.iteye.com/blog/1488302) 如果屏幕中的内容项目比较多 ...
- 手机端上点击input框软键盘出现时把input框不被覆盖,显示在屏幕中间(转)
转载地址:https://www.cnblogs.com/xzzzys/p/7526761.html 1 用定位为题来解决var oHeight = $(document).height(); // ...
- ios-利用键盘通知处理键盘出现时遮挡控件问题
-(void)viewDidLoad { NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; //注册键盘显示通知 ...
- Android 软键盘弹出,界面整体上移
在做搜索功能的时候,点击搜索框,搜索框获取焦点,键盘弹出:现在问题出来了,android软键盘弹出的时候,android整个界面上移,布局被挤压,很难看:要解决这个问题,我们需要用到 windowSo ...
- iOS之 利用通知(NSNotificationCenter)获取键盘的高度,以及显示和隐藏键盘时修改界面的注意事项
我们在开发中会遇到这样的情况:调用键盘时需要界面有一个调整,避免键盘遮掩输入框. 但实现时你会发现,在不同的手机上键盘的高度是不同的.这里列举一下: //获取键盘的高度 /* iphone 6: 中文 ...
- IOS 键盘弹出导致的position:fixed 无效问题
解决办法(还未测试): 只需要在中间部分外层div添加css样式position:fixed;top:50px; bottom:50px;overflow:scroll;就可以实现效果,无需插件.可拷 ...
- h5页面ios键盘弹出收起后页面底部留白问题
<input placeholder="验证码" type="tel" v-model="verify" maxlength=&quo ...
- iOS之按钮出现时加一个动画效果
//按钮出现时的动画效果 + (void)buttonAnimation:(UIButton *)sender { CAKeyframeAnimation *animation = [CAKeyfra ...
随机推荐
- 在VBA中调用winsock控件
如果系统没有Winsock控件的话,可以下载下面的控件MSWINSCK.OCX,然后将该文件复制到C:\Windows\System32目录下. 在VBE窗口中,从菜单"工具"-& ...
- TMS320C54x系列DSP指令和编程指南——第1章 汇编语言工具概述
第1章 汇编语言工具概述 TMS320C54x DSP的汇编语言开发工具包括: ■ Assembler ■ Archiver ■ Linker ■ Absolut ...
- 在Label中显示一段文字
Let’s create a new Xamarin.Forms PCL solution, named Greetings, using the same process described abo ...
- eclipse 工程默认编码修改 JSP编码修改
1. Window->Preferences->General->Workspace->Text file encoding 将其改为UFT-8 新建的文件即为UTF-8编码 ...
- Clustering with the ArcGIS API for Flex
Clustering is an excellent technique for visualizing lotss of point data. We've all seen application ...
- POS管理系统之新增设备入库
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"% ...
- js图片变换
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Setup Apache + PHP + MySql on Windows 10
The below steps recorded my experiences to setup the Apache + PHP + MySql on my Windows 10. 1. Downl ...
- Fastcgi介绍和php中fastcgi的应用
先看下FastCgi的一些解释: CGI全称是“通用网关接口”(Common Gateway Interface), 它可以让一个客户端,从网页浏览器向执行在Web服务器上的程序请求数据. CGI描述 ...
- sql server 行转列解决方案
主要应用case语句来解决行转列的问题 行转列问题主要分为两类 1)简单的行转列问题: 示例表: id sid course result 1 2005001 语文 ...