国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

IOS數字鍵盤左下角添加完成按鈕的實現方法

2020-02-19 15:45:41
字體:
來源:轉載
供稿:網友

Uitextfield必須為IOS開發人員所熟悉,當我們單擊uitextfield后,會彈出鍵盤,下面武林技術頻道小編帶我們一起了解IOS數字鍵盤左下角添加完成按鈕的實現方法吧!

IOS數字鍵盤左下角添加完成按鈕的實現方法

實現代碼:

- (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];         }       }     }   } } 

以上就是武林技術頻道小編為您介紹的IOS數字鍵盤左下角添加完成按鈕的實現方法,希望大家可以利用業余時間在學習到更多的知識。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 莎车县| 永德县| 太和县| 阳朔县| 太和县| 宁德市| 苍梧县| 射洪县| 荔浦县| 原阳县| 习水县| 平利县| 康马县| 阿城市| 磐安县| 紫阳县| 卢湾区| 内江市| 兖州市| 威信县| 邛崃市| 景宁| 增城市| 天峻县| 克什克腾旗| 威信县| 塔城市| 寻乌县| 广宁县| 福海县| 安宁市| 商河县| 永城市| 苍溪县| 景谷| 伊金霍洛旗| 武强县| 绥棱县| 徐州市| 平江县| 沁水县|