ios8数字键盘添加完成
来源:互联网 发布:大陆台湾网络骂战 编辑:程序博客网 时间:2024/03/28 19:51
[[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(addDoneButtonToNumPadKeyboard)name:UIKeyboardDidShowNotificationobject:nil];
//注册键盘隐藏通知
[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(removeDoneButtonFromNumPadKeyboard)name:UIKeyboardDidHideNotificationobject:nil];
- (void)addDoneButtonToNumPadKeyboard
{
UIButton *doneButton = [UIButtonbuttonWithType:UIButtonTypeCustom];
if ([[[UIDevicecurrentDevice] systemVersion]floatValue] < 8.0){
doneButton.frame =CGRectMake(0,163, 106, 53);
}else{
doneButton.frame =CGRectMake(0, self.view.frame.size.height-53,106, 53);
}
doneButton.tag =20;
doneButton.adjustsImageWhenHighlighted =NO;
[doneButton setTitle:@"完成"forState:UIControlStateNormal];
[doneButton setTitleColor:[UIColorblackColor] forState:UIControlStateNormal];
[doneButton addTarget:selfaction:@selector(doneButton:)forControlEvents:UIControlEventTouchUpInside];
NSArray *windowArr = [[UIApplicationsharedApplication] windows];
if (windowArr != nil && windowArr.count >1){
UIWindow *needWindow = [windowArr objectAtIndex:1];
UIView *keyboard;
for(int i =0; i < [needWindow.subviewscount]; i++) {
keyboard = [needWindow.subviewsobjectAtIndex:i];
NSLog(@"%@", [keyboarddescription]);
if(([[keyboard description]hasPrefix:@"<UIPeripheralHostView"] ==YES) || ([[keyboard description] hasPrefix:@"<UIKeyboard"] ==YES) || ([[keyboard description] hasPrefix:@"<UIInputSetContainerView"] ==YES)){
UIView *doneButtonView = [keyboard viewWithTag:20];
if (doneButtonView == nil){
[keyboardaddSubview:doneButton];
}
}
}
}
}
-(void)removeDoneButtonFromNumPadKeyboard
{
UIView *doneButton = nil;
NSArray *windowArr = [[UIApplicationsharedApplication] windows];
if (windowArr != nil && windowArr.count >1){
UIWindow *needWindow = [windowArr objectAtIndex:1];
UIView *keyboard;
for(int i =0; i < [needWindow.subviewscount]; i++) {
keyboard = [needWindow.subviewsobjectAtIndex:i];
if(([[keyboard description]hasPrefix:@"<UIPeripheralHostView"] ==YES) || ([[keyboard description] hasPrefix:@"<UIKeyboard"] ==YES) || ([[keyboard description] hasPrefix:@"<UIInputSetContainerView"] ==YES)){
doneButton = [keyboardviewWithTag:20];
if (doneButton != nil){
[doneButtonremoveFromSuperview];
}
}
}
}
}
- ios8数字键盘添加完成
- iOS8数字键盘左下角添加完成按钮
- iOS8数字键盘左下角添加完成按钮的核心代码如下:
- 给数字键盘添加完成按钮的坑
- ios在数字键盘左下角添加“完成”按钮的实现原理
- ios隐藏数字键盘 --在数字键盘左下角添加“完成”按钮的实现原理
- iOS 数字键盘完成键
- 数字键盘添加自定义按钮
- 数字键盘添加自定义按钮
- 数字键盘添加自定义按钮
- iOS 之给苹果自带的纯数字键盘添加完成事件
- (判断第三方输入法)在系统数字键盘上添加“完成”按钮引发的问题思考
- iOS8 数字键盘添加自定义按钮(兼容各个版本以及解决自定义按钮滑动出现的问题)
- 在数字键盘上添加button
- 【在数字键盘上添加button】
- 为iphone的数字键盘添加done按键
- 为iphone的数字键盘添加"return"key
- 数字键盘添加自定义按钮(转自cocoachina)
- bit传送
- Android启动默认是横屏或者竖屏
- UVA OJ Bicoloring 10004
- mms 数据包相关 抓包
- malloc/free
- ios8数字键盘添加完成
- Automatic Preferred Max Layout Width is not available on
- 英语四六级考试网(个人测试)
- HTTP请求辅助类
- oracle表空间详解--原理
- 程序员的核心竞争力:什么是能力?这就是能力
- 电子商务网站的设计与实现(二):一期功能清单
- 中国矿业大学学生在线入围第七届全国高校百佳网站——获得“最佳技术应用奖”
- 解决jsp重复提交问题