当文本输入时, 文本框有几中选择用于辅助输入:

textField.clearButtonMode = UITextFieldViewModeWhileEditing;

Java代码 
  1. typedef enum {
  2. UITextFieldViewModeNever, //clear button 永远不出现
  3. UITextFieldViewModeWhileEditing, //编辑的时候出现
  4. UITextFieldViewModeUnlessEditing, //未编辑的时候出现
  5. UITextFieldViewModeAlways //永远都出现
  6. } UITextFieldViewMode;

弹出的键盘类型也可以辅助快速输入:

textField.keyboardType = UIKeyboardTypeAlphabet;

Java代码 
  1. typedef enum {
  2. UIKeyboardTypeDefault,                // Default type for the current input method.
  3. UIKeyboardTypeASCIICapable,           // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active
  4. UIKeyboardTypeNumbersAndPunctuation,  // Numbers and assorted punctuation.
  5. UIKeyboardTypeURL,                    // A type optimized for URL entry (shows . / .com prominently).
  6. UIKeyboardTypeNumberPad,              // A number pad (0-9). Suitable for PIN entry.
  7. UIKeyboardTypePhonePad,               // A phone pad (1-9, *, 0, #, with letters under the numbers).
  8. UIKeyboardTypeNamePhonePad,           // A type optimized for entering a person's name or phone number.
  9. UIKeyboardTypeEmailAddress,           // A type optimized for multiple email address entry (shows space @ . prominently).
  10. UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, // Deprecated
  11. } UIKeyboardType;

键盘的呈现风格:

textField..keyboardAppearance = UIKeyboardAppearanceAlert;

Java代码 
  1. typedef enum {
  2. UIKeyboardAppearanceDefault,          // Default apperance for the current input method.
  3. UIKeyboardAppearanceAlert,            // Appearance suitable for use in "alert" scenarios.
  4. } UIKeyboardAppearance;

键盘对输入字母的控制:

textField.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;

Java代码 
  1. typedef enum {
  2. UITextAutocapitalizationTypeNone, //什么也不做
  3. UITextAutocapitalizationTypeWords, //单词首字母大写
  4. UITextAutocapitalizationTypeSentences, //句子首字母大些
  5. UITextAutocapitalizationTypeAllCharacters, //所有字母大些
  6. } UITextAutocapitalizationType;

键盘对输入字母自动纠正

textField.autocorrectionType = UITextAutocorrectionTypeYes;

Java代码 
  1. typedef enum {
  2. UITextAutocorrectionTypeDefault,
  3. UITextAutocorrectionTypeNo,
  4. UITextAutocorrectionTypeYes,
  5. } UITextAutocorrectionType;

确认键的类型

textField.returnKeyType = UIReturnKeyDone;

Java代码 
  1. typedef enum {
  2. UIReturnKeyDefault,
  3. UIReturnKeyGo,
  4. UIReturnKeyGoogle,
  5. UIReturnKeyJoin,
  6. UIReturnKeyNext,
  7. UIReturnKeyRoute,
  8. UIReturnKeySearch,
  9. UIReturnKeySend,
  10. UIReturnKeyYahoo,
  11. UIReturnKeyDone,
  12. UIReturnKeyEmergencyCall,
  13. } UIReturnKeyType;

最后一个技巧,也是网上收集,键盘透明以及增加一个按键的应用:

[[NSNotificationCenter defaultCenter] addObserver:self

Java代码 
  1. selector:@selector(keyboardWillShow:)
  2. name:UIKeyboardWillShowNotification
  3. object:nil];
  4. --------------------
  5. - (void)keyboardWillShow:(NSNotification *)note {
  6. // create custom button
  7. UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
  8. doneButton.frame = CGRectMake(0, 163, 106, 53);
  9. doneButton.adjustsImageWhenHighlighted = NO;
  10. [doneButton setImage:[UIImage imageNamed:@"DoneUp.png"] forState:UIControlStateNormal];
  11. [doneButton setImage:[UIImage imageNamed:@"DoneDown.png"] forState:UIControlStateHighlighted];
  12. [doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];
  13. // locate keyboard view
  14. UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
  15. UIView* keyboard;
  16. for(int i=0; i<[tempWindow.subviews count]; i++) {
  17. keyboard = [tempWindow.subviews objectAtIndex:i];
  18. // keyboard view found; add the custom button to it
  19. if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
  20. [keyboard addSubview:doneButton];
  21. }
  22. }

转载于:https://www.cnblogs.com/encounter/archive/2010/08/24/2188540.html

iphone 软键盘相关推荐

  1. storyboard隐藏iphone软键盘

    xcode 4.3.2  storyboard ** 点击软键盘的return键隐藏软键盘 .h文件定义IBAction -(IBAction)textFieldReturn:(id)sender; ...

  2. iphone 软键盘设置参数说明

    当文本输入时, 文本框有几中选择用于辅助输入: textField.clearButtonMode = UITextFieldViewModeWhileEditing; typedef enum { ...

  3. js手机键盘遮挡_iphone手机微信页面软键盘遮挡input输入框解决方法

    现象描述:iphone手机微信页面,用position: fixed;定位的input或textarea输入框,在获取输入焦点时,会被弹出的输入法软键盘遮挡,导致用户无法看到输入框,效果如图: 简化测 ...

  4. vant 软键盘_移动端页面输入底部被软键盘遮挡问题

    概述 近期有个移动端页面的项目,存在需要用户输入的表单信息.因为页面不存在滑动(通过overflow设为hidden的方式),所以在点击input标签输入信息时,在安卓机下键盘会遮挡页面底部内容,当点 ...

  5. vue 全局键盘_如何解决ios input框唤起软键盘不灵敏问题?

    为什么移动端点击事件要加300ms延迟呢? 早在 2007 年初,苹果公司在发布首款 iPhone 前夕,遇到一个问题:当时的网站都是为大屏幕设备所设计的.于是苹果的工程师们做了一些约定,应对 iPh ...

  6. 移动端H5页面关于软键盘的一些踩坑记录

    最近一个项目需要做一个留言的功能,需求很简单,点击留言按钮底部弹出留言框,然后发送留言给后台就行了,还有一个就是页面要实现复制功能.讨论需求的时候我预想到了手机上软键盘的弹出可能会有一些bug,不过需 ...

  7. vh布局移动端软键盘弹起改变高度问题

    问题描述 在移动端使用vh布局.当页面中包含input.textarea输入框的时候,或者有调起软键盘的操作时,安卓浏览器下,可视窗口的高度改变,导致页面上的vh重新计算,页面被压扁.ios下的浏览器 ...

  8. 天津达内聊H5 软键盘兼容方案

    最近一段时间在做 H5 聊天项目,过程中踩过一个大坑:输入框获取焦点,软键盘弹起,要求输入框吸附(或顶)在输入法框上.需求很明确,看似很简单,其实不然.作者实验了一些机型,发现了一些问题,并且逐一探索 ...

  9. ios使用el-select的远程搜索无法唤起软键盘

    首先根据网上的方法找到解决软键盘不能弹起问题 <template><el-selectref="select"@hook:mounted="cancal ...

最新文章

  1. iView 发布 1.0 正式版,43 个 UI 组件助力中后台业务开发
  2. GridView导出到Excel和开源图表工具
  3. 一个人的成功取决于晚上的8点至10点--经典语录必读
  4. JVM学习04:类的文件结构
  5. PopupMenu控件的使用
  6. Python中的from import和import的区别?没有比这回答的更好了
  7. 统计自己洛谷AC题目爬虫
  8. Git修改已提交的commit
  9. 模板类的析构函数如何写_项目经理如何正确写好年终总结+10大PPT模板可直接套用...
  10. 启明星win7桌面天气预报软件下载与使用方法(带时间)
  11. [bzoj3481]dzy loves math III 解题报告
  12. SOHUDBA/SOHU-DBProxy: 搜狐公司强大的数据库中间件
  13. QObject::connect: Cannot connect QTimer::timeout() to (null)::fuction()
  14. 读书笔记_006 《查令十字街84号》
  15. Openstack 发行版本列表
  16. Verdi调整字体大小
  17. Canvas响应 -岛岛还存活在代码的第79天-
  18. oracle1034错误,联接oracle数据库,返回-1034,搞了两天没搞定!
  19. windows, pip install xgboost 出现错误:No files/directories in ******
  20. 一图带你了解人工智能简史

热门文章

  1. 如何快速判断某 URL 是否在 20 亿的网址 URL 集合中?
  2. 微服务架构·基础篇,傻瓜看了都会
  3. 干货!!!MySQL 大表优化方案(1)
  4. Java常量池的大概理解
  5. 给老婆普及计算机知识
  6. Java Streams,第 2 部分: 使用流执行聚合
  7. Git : 将本地git仓库同步到远端github上
  8. 48.聊一聊constexpr变量
  9. 【Scratch】青少年蓝桥杯_每日一题_1.9_小猫旅行
  10. Android --- 怎么把其他类型的数据转换成 Json 字符串