iOS模拟器键盘的下面添加一个完成按钮
来源:互联网 发布:u盘raw格式数据恢复 编辑:程序博客网 时间:2024/05/01 17:26
前言
为了满足一些用户的特殊需求,可能有的用户希望在键盘的左下角添加一个完成按钮,就像微信的右下角可以切换成"发送"和"换行"两个功能,所以我上网找了一些资料,整理了一下,大概的核心代码就是下面这些
- - (void)addDoneButtonToNumPadKeyboard
- {
- UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
- if (systemVersion < 8.0){
- doneButton.frame = CGRectMake(0, 163, 106, 53);
- }else{
- doneButton.frame = CGRectMake(0, SCREEN_SIZE.height-53, 106, 53);
- }
- doneButton.tag = NUM_PAD_DONE_BUTTON_TAG;
- doneButton.adjustsImageWhenHighlighted = NO;
- [doneButton setTitle:@"完成" forState:UIControlStateNormal];
- [doneButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- [doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];
- NSArray *windowArr = [[UIApplication sharedApplication] windows];
- if (windowArr != nil && windowArr.count > 1){
- UIWindow *needWindow = [windowArr objectAtIndex:1];
- UIView *keyboard;
- for(int i = 0; i < [needWindow.subviews count]; i++) {
- keyboard = [needWindow.subviews objectAtIndex:i];
- NSLog(@"%@", [keyboard description]);
- if(([[keyboard description] hasPrefix:@"<UIPeripheralHostView"] == YES) || ([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES) || ([[keyboard description] hasPrefix:@"<UIInputSetContainerView"] == YES)){
- UIView *doneButtonView = [keyboard viewWithTag:NUM_PAD_DONE_BUTTON_TAG];
- if (doneButtonView == nil){
- [keyboard addSubview:doneButton];
- }
- }
- }
- }
- }
- -(void)removeDoneButtonFromNumPadKeyboard
- {
- UIView *doneButton = nil;
- NSArray *windowArr = [[UIApplication sharedApplication] windows];
- if (windowArr != nil && windowArr.count > 1){
- UIWindow *needWindow = [windowArr objectAtIndex:1];
- UIView *keyboard;
- for(int i = 0; i < [needWindow.subviews count]; i++) {
- keyboard = [needWindow.subviews objectAtIndex:i];
- if(([[keyboard description] hasPrefix:@"<UIPeripheralHostView"] == YES) || ([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES) || ([[keyboard description] hasPrefix:@"<UIInputSetContainerView"] == YES)){
- doneButton = [keyboard viewWithTag:NUM_PAD_DONE_BUTTON_TAG];
- if (doneButton != nil){
- [doneButton removeFromSuperview];
- }
- }
- }
- }
- }
0 0
- iOS模拟器键盘的下面添加一个完成按钮
- iOS 数字输入键盘添加一个完成按钮
- ios在 键盘左下角添加“完成”按钮的实现原理
- ios 键盘右上角添加完成按钮
- 给键盘添加一个tooBar,完成按钮,以及对写一个分类的理解
- iOS 给键盘上方添加 收回键盘的按钮
- IOS 键盘右上角完成按钮自定义
- ios在数字键盘左下角添加“完成”按钮的实现原理
- 隐藏键盘,在键盘上部添加一个取消键盘的按钮
- textView 弹出键盘上面添加完成按钮,并设置输入内容的格式。
- iOS虚拟键盘上添加动态按钮
- iOS虚拟键盘上添加动态按钮
- UITextField在弹出的键盘上方,加一个带有完成按钮的toolBar工具栏
- iOS开发:真机或者模拟器中,APP中的按钮文字下面自动出现下划线的问题的解决
- 利用 java.awt.Robot 类来自动完成一些键盘或鼠标的动作,下面是一个小例子
- iOS给键盘添加一个简单的输入框
- ListView下面添加一个按钮(更多)加载更多数据
- 给数字键盘添加完成按钮的坑
- 九月总结
- 实验一.3
- 剑指offer—用两个栈实现队列
- 9月英语小结
- LeetCode Climb Stairs
- iOS模拟器键盘的下面添加一个完成按钮
- ZooKeeper
- 生活感悟
- 【软考3】知识点的宏观总结
- 传感器的使用:方向传感器
- Git使用教程2:版本库的创建和添加文件
- 剑指offer—旋转数组的最小数字
- 编程之美变形记——“49”的个数
- 安装完ADT插件选择SDK manager时的错误 Could not find folder"tools"