IOS UI-键盘处理和UIToolbar
//
// ViewController.m
// IOS_0225-键盘处理和UIToolBar
//
// Created by ma c on 16/2/25.
// Copyright © 2016年 博文科技. All rights reserved.
// #import "ViewController.h" @interface ViewController () @property (nonatomic, strong) UITextField *textField; @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor cyanColor]; [self createTextField];
} - (void)createTextField
{
self.textField = [[UITextField alloc] initWithFrame:CGRectMake(, , , 44.0)];
self.textField.borderStyle = UITextBorderStyleRoundedRect;
self.textField.placeholder = @"请输入内容";
self.textField.clearButtonMode = UITextFieldViewModeAlways;
[self.view addSubview:self.textField]; //自定义文本框的键盘
self.textField.inputView = [UIButton buttonWithType:UIButtonTypeContactAdd];
//自定义文本框上面的辅助工具控件
UIToolbar *toolBar = [[UIToolbar alloc] init];
[toolBar sizeToFit];
toolBar.barTintColor = [UIColor redColor]; UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@"上一个" style:UIBarButtonItemStylePlain target:self action:@selector(previewClick)];
UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"下一个" style:UIBarButtonItemStylePlain target:self action:@selector(nextClick)];
UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
UIBarButtonItem *item4 = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(doneClick)];
toolBar.items = @[item1,item2,item3,item4];
self.textField.inputAccessoryView = toolBar; } - (void)previewClick
{
NSLog(@"上一个");
} - (void)nextClick
{
NSLog(@"下一个");
} - (void)doneClick
{
[self.view endEditing:YES];
} @end
IOS UI-键盘处理和UIToolbar的更多相关文章
- ios中键盘处理源码
1:先分别设置各个文本框的键盘类型(inputview)-->在特定键盘中textediting中禁用输入. 2:然后递归绑定各个键盘的工具条(inputaccessview).并且个各个控 ...
- 【iOS自定义键盘及键盘切换】详解
[iOS自定义键盘]详解 实现效果展示: 一.实现的协议方法代码 #import <UIKit/UIKit.h> //创建自定义键盘协议 @protocol XFG_KeyBoardDel ...
- iOS 收起键盘的几种方式
iOS 收起键盘的几种方式 1.一般的view上收起键盘 // 手势 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ ...
- ios 自定义键盘
由于项目需要,需要自定义键盘.ios系统键盘会缓存键盘输入,并保存在系统目录下的文件里,并且是明文存储,存在帐号密码泄漏风险.在别人代码基础上修改了下,美化了下界面,去掉了字符输入,加了点击特效,截图 ...
- IOS 回收键盘通用代码
感觉IOS的键盘回收好累,所以封装了一个通用一点的方法 -(IBAction)spbResignFirstResponder:(id)sender { // NSLogObj(sender); if ...
- [IOS]IOS UI指南
[IOS]IOS UI指南 众所周知,IOS的界面设计,越来越流行,可以说都形成了一个标准,搜集了一些资料,供自己以后学习使用! iOS Human Interface Guidelines (中文翻 ...
- IOS UI 第八篇:基本UI
实现图片的滚动,并且自动停止在每张图片上 - (void)viewDidLoad{ [super viewDidLoad]; UIScrollView *scrollView = [[U ...
- iOS学习——键盘弹出遮挡输入框问题解决方案
在iOS或Android等移动端开发过程中,经常遇到很多需要我们输入信息的情况,例如登录时要输入账号密码.查询时要输入查询信息.注册或申请时需要填写一些信息等都是通过我们键盘来进行输入的,在iOS开发 ...
- iOS 解决键盘挡住输入框的问题
iOS开发中经常会用到输入框UITextField,所以也常会遇到键盘挡住输入框而看不到输入框的内容. 在这里记录一种方法,用UITextField的代理来实现View的上移来解决这个问题. 首先设置 ...
随机推荐
- 设置 Quick-Cocos2d-x 在 Windows 下的编译环境
http://cn.cocos2d-x.org/tutorial/show?id=1304 设置 Quick-Cocos2d-x 在 Windows 下的编译环境 Liao Yulei2014-08- ...
- PKU 2352 Stars(裸一维树状数组)
题目大意:原题链接 就是求每个小星星左小角的星星的个数.坐标按照Y升序,Y相同X升序的顺序给出由于y轴已经排好序,可以按照x坐标建立一维树状数组 关键是要理解树状数组中的c[maxn]数组的构成方式, ...
- Codeforces Round #425 (Div. 2) C - Strange Radiation
地址:http://codeforces.com/contest/832/problem/C 题目: C. Strange Radiation time limit per test 3 second ...
- maven install jdk版本自动降为1.7
开发过程中遇到了一个奇怪的现象. IDEA中所有的设置都改成了1.8,但是在执行maven install时却自动降为1.7,报错提示: [ERROR] Failed to execute goal ...
- 保持简单----纪念丹尼斯•里奇(Dennis Ritchie)
http://www.ruanyifeng.com/blog/2011/10/dennis_ritchie.html
- Java命令:Jstack
jstack是java虚拟机自带的一种堆栈跟踪工具. 功能 jstack用于生成java虚拟机当前时刻的线程快照.线程快照是当前java虚拟机内每一条线程正在执行的方法堆栈的集合,生成线程快照的主要目 ...
- java获取时间戳
package com.ycy.test; import java.text.SimpleDateFormat; import java.util.Date; public class ItemsCo ...
- centos7 安装 gitolite (git服务器)
gitolite简介 轻量级git服务器程序,解决了git权限管理的问题.(git是一个分布式版本控制系统,就是说每个人作为客户端的同时又是服务器)项目GitHub地址:https://github. ...
- Python爬虫学习笔记之爬虫基础库
知识预览 beautifulsoup的简单使用 beautifulsoup的遍历文档树 beautifulsoup的搜索文档树 beautifulsoup的css选择器 回到顶部 beautifuls ...
- jquery阻止事件冒泡的方法
$("table tbody").click(function(e) { e.preventDefault(); //阻止自身的事件,并不能阻止冒泡 e.stopPropagati ...