UITextField 键盘上弹出"完成"字样
2016-09-14 15:31
295 查看
#import <UIKit/UIKit.h>
@interface QYTextField :
UITextField
@property (nonatomic,strong)
UIToolbar *toolbar;
@end
#import "QYTextField.h"
@implementation QYTextField
- (id)initWithFrame:(CGRect)frame{
self = [superinitWithFrame:frame];
if (self) {
[self setup];
}
return
self;
}
- (void)setup{
self.toolbar = [[UIToolbaralloc]
init];
self.toolbar.frame =CGRectMake(0,0,
self.window.frame.size.width,44);
// set style
[self.toolbarsetBarStyle:UIBarStyleDefault];
UIBarButtonItem *flexBarButton = [[UIBarButtonItemalloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpacetarget:nilaction:nil];
UIBarButtonItem *doneBarButton = [[UIBarButtonItemalloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDonetarget:selfaction:@selector(doneButtonIsClicked:)];
NSArray *barButtonItems =
@[flexBarButton, doneBarButton];
self.toolbar.items = barButtonItems;
[selfsetInputAccessoryView:self.toolbar];
}
- (void) doneButtonIsClicked:(id)sender{
[selfresignFirstResponder];
}
@interface QYTextField :
UITextField
@property (nonatomic,strong)
UIToolbar *toolbar;
@end
#import "QYTextField.h"
@implementation QYTextField
- (id)initWithFrame:(CGRect)frame{
self = [superinitWithFrame:frame];
if (self) {
[self setup];
}
return
self;
}
- (void)setup{
self.toolbar = [[UIToolbaralloc]
init];
self.toolbar.frame =CGRectMake(0,0,
self.window.frame.size.width,44);
// set style
[self.toolbarsetBarStyle:UIBarStyleDefault];
UIBarButtonItem *flexBarButton = [[UIBarButtonItemalloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpacetarget:nilaction:nil];
UIBarButtonItem *doneBarButton = [[UIBarButtonItemalloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDonetarget:selfaction:@selector(doneButtonIsClicked:)];
NSArray *barButtonItems =
@[flexBarButton, doneBarButton];
self.toolbar.items = barButtonItems;
[selfsetInputAccessoryView:self.toolbar];
}
- (void) doneButtonIsClicked:(id)sender{
[selfresignFirstResponder];
}
相关文章推荐
- easyui tree 点击文字打开或者闭合
- AndroidStudio-Eat-Guide—— 1.下载安装配置
- @RequestMaping的用法
- Coding 初级教程(一)——用GitHub的GUI客户端对Coding的项目进行管理
- mui日期选择器弹出两次的解决方法
- easyui datagrid 列拖动
- iOS开发 UILocalNotification 本地通知实现提醒功能
- android W/View: requestLayout() improperly called by xxxView
- StringBuilder的实现与技巧
- Codeforces Round #371 (Div. 2)(set\unique)
- 详解XMLHttpRequest(二)响应属性、二进制数据、监测上传下载进度
- UGUI内核大探究(五)Toggle与ToggleGroup
- 前端框架——AmazeUI学习
- HDU 5869 Different GCD Subarray Query rmq+离线+数状数组
- easyUI中combobox的使用方法
- 详解XMLHttpRequest(一)同步请求和异步请求
- Codeforces Round #371 (Div. 2)C. Sonya and Queries
- UIAlertView 按钮顺序
- codeforces 714C Sonya and Queries [思维]【STL】
- Codeforces #371(Div.2)C.Sonya and Queries【map应用】【思维】