iOS之UITextView的使用——通过虚拟键盘的工具条关闭虚拟键盘
来源:互联网 发布:淘宝众筹不发货怎么办 编辑:程序博客网 时间:2024/05/17 05:04
1、.h
#import <UIKit/UIKit.h>@interface FKViewController : UIViewController <UITextViewDelegate>@property (strong, nonatomic) IBOutlet UITextView *textView;@end
2、.m
#import "FKViewController.h"@interface FKViewController ()@end@implementation FKViewController- (void)viewDidLoad{[super viewDidLoad];// 创建一个UIToolBar工具条UIToolbar * topView = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 30)];// 设置工具条风格[topView setBarStyle:UIBarStyleDefault];// 为工具条创建第1个“按钮”UIBarButtonItem* myBn = [[UIBarButtonItem alloc]initWithTitle:@"无动作"style:UIBarButtonItemStyleBorderedtarget:self action:nil];// 为工具条创建第2个“按钮”,该按钮只是一片可伸缩的空白区。UIBarButtonItem* spaceBn = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpacetarget:self action:nil];// 为工具条创建第3个“按钮”,单击该按钮会激发editFinish方法UIBarButtonItem* doneBn = [[UIBarButtonItem alloc]initWithTitle:@"完成"style:UIBarButtonItemStyleDonetarget:self action:@selector(editFinish)];// 以3个按钮创建NSArray集合NSArray * buttonsArray = [NSArray arrayWithObjects:myBn,spaceBn,doneBn,nil];// 为UIToolBar设置按钮[topView setItems:buttonsArray];// 为textView关联的虚拟键盘设置附件[self.textView setInputAccessoryView:topView];}- (void) didReceiveMemoryWarning{[super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}-(void) editFinish{[self.textView resignFirstResponder];}@end通过storyboard布局
0 0
- iOS之UITextView的使用——通过虚拟键盘的工具条关闭虚拟键盘
- iOS之UITextView的使用——使用导航栏关闭虚拟键盘
- iOS中关闭虚拟键盘的方法
- IOS学习之——关闭ios虚拟键盘的几种方法
- iOS关闭虚拟键盘
- iOS关闭虚拟键盘
- IOS关闭虚拟键盘
- iOS开发之自定义键盘附件关闭虚拟键盘
- IOS开发 关闭虚拟键盘的各种方式
- 关闭iOS虚拟键盘的六种方法
- 关闭ios虚拟键盘的几种方法
- 关闭ios虚拟键盘的几种方法
- 关闭iOS虚拟键盘的N种方法
- 关闭ios虚拟键盘的几种方法
- 关闭ios虚拟键盘的几种方法
- 关闭ios虚拟键盘的几种实用方法
- 关闭ios虚拟键盘的几种方法
- 关闭ios虚拟键盘的几种方法
- OpenStack商业生态圈分析
- 恶补web之二:css知识(1)
- java压缩zip文件中文乱码问题
- HTML+CSS基础课程
- NPOI 2.1.1 binary-第三方控件读取execl
- iOS之UITextView的使用——通过虚拟键盘的工具条关闭虚拟键盘
- Java初学习 - Runnable接口 和 同步代码块synchronized
- 机器学习研究
- 异步交互(二)
- Apache服务器无法使用的问题分析及解决方法
- 微信分享到朋友圈和会话
- 解决 - java.lang.OutOfMemoryError: unable to create new native thread
- Dijkstra, Dijkstra. - UVa 10806 费用流
- 三维模型的网格细化