iOS 键盘
2016-07-01 11:44
573 查看
键盘类型
【监控键盘的出现和隐藏】
【键盘的高度】
typedef enum { UIKeyboardTypeDefault, 默认键盘,支持所有字符 UIKeyboardTypeASCIICapable, 支持ASCII的默认键盘 UIKeyboardTypeNumbersAndPunctuation, 标准电话键盘,支持+*#字符 UIKeyboardTypeURL, URL键盘,支持.com按钮 只支持URL字符 UIKeyboardTypeNumberPad, 数字键盘 UIKeyboardTypePhonePad, 电话键盘 UIKeyboardTypeNamePhonePad, 电话键盘,也支持输入人名 UIKeyboardTypeEmailAddress, 用于输入电子 邮件地址的键盘 UIKeyboardTypeDecimalPad, 数字键盘 有数字和小数点 UIKeyboardTypeTwitter, 优化的键盘,方便输入@、#字符 UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, } UIKeyboardType;
【监控键盘的出现和隐藏】
//键盘的出现 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardDidShowNotification object:nil]; //键盘的隐藏 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasDismiss:) name:UIKeyboardDidHideNotification object:nil];
【键盘的高度】
//实现当键盘出现的时候计算键盘的高度大小。用于输入框显示位置 - (void)keyboardWasShown:(NSNotification*)aNotification { NSDictionary* info = [aNotification userInfo]; //kbSize为键盘尺寸 CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;//键盘的高度 if(kbSize.height == 216) { keyboardhight = 0; } else { keyboardhight = 36; //252 - 216 系统键盘的两个不同高度 } } //输入结束时调用动画(把按键。背景。输入框都移下去) -(void)textViewDidEndEditing:(UITextView *)textView { NSLog(@"tabtabtab"); [self endEditAnimation]; //释放 [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil]; }
相关文章推荐
- iOS外传——偷懒之路(1)
- VoiceOver经验
- ios获取当前视图所在的viewController
- iOS VoiceOver编程指南
- VoiceOver
- IOS中常用的设计模式
- IOS中正则表达式的使用
- h264解码异常处理(iOS)
- 推荐大家在GitHub 上值得关注学习的 iOS 开源项目
- 推荐大家在GitHub 上值得关注学习的 iOS 开源项目
- IOS 高德地图获取用户导航路径
- iOS开发学习路线和规划
- iOS 友盟分享 <小白集成>
- iOS-关于多线程
- iOS分类(category),类扩展(extension)—史上最全攻略
- 如何在Release版本应用中删除NSAssert()断言
- iOS保存密码之钥匙串操作以及UDID设备唯一标识符获取的替代方法
- ios 中使用xib拖拽的scrollview中子控件位置偏移
- iOS --TableView与NavigationBar中间多出空白间隔
- iOS--坐标变换Quartz 2D中的CGContextTranslateCTM、CGContextScaleCTM、