iphone 软键盘
当文本输入时, 文本框有几中选择用于辅助输入:
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
- typedef enum {
- UITextFieldViewModeNever, //clear button 永远不出现
- UITextFieldViewModeWhileEditing, //编辑的时候出现
- UITextFieldViewModeUnlessEditing, //未编辑的时候出现
- UITextFieldViewModeAlways //永远都出现
- } UITextFieldViewMode;
弹出的键盘类型也可以辅助快速输入:
textField.keyboardType = UIKeyboardTypeAlphabet;
- typedef enum {
- UIKeyboardTypeDefault, // Default type for the current input method.
- UIKeyboardTypeASCIICapable, // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active
- UIKeyboardTypeNumbersAndPunctuation, // Numbers and assorted punctuation.
- UIKeyboardTypeURL, // A type optimized for URL entry (shows . / .com prominently).
- UIKeyboardTypeNumberPad, // A number pad (0-9). Suitable for PIN entry.
- UIKeyboardTypePhonePad, // A phone pad (1-9, *, 0, #, with letters under the numbers).
- UIKeyboardTypeNamePhonePad, // A type optimized for entering a person's name or phone number.
- UIKeyboardTypeEmailAddress, // A type optimized for multiple email address entry (shows space @ . prominently).
- UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, // Deprecated
- } UIKeyboardType;
键盘的呈现风格:
textField..keyboardAppearance = UIKeyboardAppearanceAlert;
- typedef enum {
- UIKeyboardAppearanceDefault, // Default apperance for the current input method.
- UIKeyboardAppearanceAlert, // Appearance suitable for use in "alert" scenarios.
- } UIKeyboardAppearance;
键盘对输入字母的控制:
textField.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;
- typedef enum {
- UITextAutocapitalizationTypeNone, //什么也不做
- UITextAutocapitalizationTypeWords, //单词首字母大写
- UITextAutocapitalizationTypeSentences, //句子首字母大些
- UITextAutocapitalizationTypeAllCharacters, //所有字母大些
- } UITextAutocapitalizationType;
键盘对输入字母自动纠正
textField.autocorrectionType = UITextAutocorrectionTypeYes;
- typedef enum {
- UITextAutocorrectionTypeDefault,
- UITextAutocorrectionTypeNo,
- UITextAutocorrectionTypeYes,
- } UITextAutocorrectionType;
确认键的类型
textField.returnKeyType = UIReturnKeyDone;
- typedef enum {
- UIReturnKeyDefault,
- UIReturnKeyGo,
- UIReturnKeyGoogle,
- UIReturnKeyJoin,
- UIReturnKeyNext,
- UIReturnKeyRoute,
- UIReturnKeySearch,
- UIReturnKeySend,
- UIReturnKeyYahoo,
- UIReturnKeyDone,
- UIReturnKeyEmergencyCall,
- } UIReturnKeyType;
最后一个技巧,也是网上收集,键盘透明以及增加一个按键的应用:
[[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(keyboardWillShow:)
- name:UIKeyboardWillShowNotification
- object:nil];
- --------------------
- - (void)keyboardWillShow:(NSNotification *)note {
- // create custom button
- UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
- doneButton.frame = CGRectMake(0, 163, 106, 53);
- doneButton.adjustsImageWhenHighlighted = NO;
- [doneButton setImage:[UIImage imageNamed:@"DoneUp.png"] forState:UIControlStateNormal];
- [doneButton setImage:[UIImage imageNamed:@"DoneDown.png"] forState:UIControlStateHighlighted];
- [doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];
- // locate keyboard view
- UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
- UIView* keyboard;
- for(int i=0; i<[tempWindow.subviews count]; i++) {
- keyboard = [tempWindow.subviews objectAtIndex:i];
- // keyboard view found; add the custom button to it
- if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
- [keyboard addSubview:doneButton];
- }
- }
转载于:https://www.cnblogs.com/encounter/archive/2010/08/24/2188540.html
iphone 软键盘相关推荐
- storyboard隐藏iphone软键盘
xcode 4.3.2 storyboard ** 点击软键盘的return键隐藏软键盘 .h文件定义IBAction -(IBAction)textFieldReturn:(id)sender; ...
- iphone 软键盘设置参数说明
当文本输入时, 文本框有几中选择用于辅助输入: textField.clearButtonMode = UITextFieldViewModeWhileEditing; typedef enum { ...
- js手机键盘遮挡_iphone手机微信页面软键盘遮挡input输入框解决方法
现象描述:iphone手机微信页面,用position: fixed;定位的input或textarea输入框,在获取输入焦点时,会被弹出的输入法软键盘遮挡,导致用户无法看到输入框,效果如图: 简化测 ...
- vant 软键盘_移动端页面输入底部被软键盘遮挡问题
概述 近期有个移动端页面的项目,存在需要用户输入的表单信息.因为页面不存在滑动(通过overflow设为hidden的方式),所以在点击input标签输入信息时,在安卓机下键盘会遮挡页面底部内容,当点 ...
- vue 全局键盘_如何解决ios input框唤起软键盘不灵敏问题?
为什么移动端点击事件要加300ms延迟呢? 早在 2007 年初,苹果公司在发布首款 iPhone 前夕,遇到一个问题:当时的网站都是为大屏幕设备所设计的.于是苹果的工程师们做了一些约定,应对 iPh ...
- 移动端H5页面关于软键盘的一些踩坑记录
最近一个项目需要做一个留言的功能,需求很简单,点击留言按钮底部弹出留言框,然后发送留言给后台就行了,还有一个就是页面要实现复制功能.讨论需求的时候我预想到了手机上软键盘的弹出可能会有一些bug,不过需 ...
- vh布局移动端软键盘弹起改变高度问题
问题描述 在移动端使用vh布局.当页面中包含input.textarea输入框的时候,或者有调起软键盘的操作时,安卓浏览器下,可视窗口的高度改变,导致页面上的vh重新计算,页面被压扁.ios下的浏览器 ...
- 天津达内聊H5 软键盘兼容方案
最近一段时间在做 H5 聊天项目,过程中踩过一个大坑:输入框获取焦点,软键盘弹起,要求输入框吸附(或顶)在输入法框上.需求很明确,看似很简单,其实不然.作者实验了一些机型,发现了一些问题,并且逐一探索 ...
- ios使用el-select的远程搜索无法唤起软键盘
首先根据网上的方法找到解决软键盘不能弹起问题 <template><el-selectref="select"@hook:mounted="cancal ...
最新文章
- iView 发布 1.0 正式版,43 个 UI 组件助力中后台业务开发
- GridView导出到Excel和开源图表工具
- 一个人的成功取决于晚上的8点至10点--经典语录必读
- JVM学习04:类的文件结构
- PopupMenu控件的使用
- Python中的from import和import的区别?没有比这回答的更好了
- 统计自己洛谷AC题目爬虫
- Git修改已提交的commit
- 模板类的析构函数如何写_项目经理如何正确写好年终总结+10大PPT模板可直接套用...
- 启明星win7桌面天气预报软件下载与使用方法(带时间)
- [bzoj3481]dzy loves math III 解题报告
- SOHUDBA/SOHU-DBProxy: 搜狐公司强大的数据库中间件
- QObject::connect: Cannot connect QTimer::timeout() to (null)::fuction()
- 读书笔记_006 《查令十字街84号》
- Openstack 发行版本列表
- Verdi调整字体大小
- Canvas响应 -岛岛还存活在代码的第79天-
- oracle1034错误,联接oracle数据库,返回-1034,搞了两天没搞定!
- windows, pip install xgboost 出现错误:No files/directories in ******
- 一图带你了解人工智能简史