一直往下拉有截图,忍不住啰嗦的朋友看图先!
以前有篇文章发了个键盘,现在这个把代码和功能优化了些许,介绍一下键盘功能:
(1)支持数字、小写字母、大写字母切换
(2)实现长按删除键可持续删除(用了个定时器,为了实现这个功能,可是煞费苦心呐,呵呵)
(3)可预设置默认出现的是数字键盘还是字母键盘(当然稍微修改可以控制只能输入数字或只能输入字母)
(4)可预设置是否是密码输入框
(5)稍作修改可用于ipad版本上,用弹出框弹出键盘
现在这个键盘还有很高的优化空间,由于现在本人没时间和精力就弄到这,足够现在的项目用了,下载的朋友如果有时间可以给优化下顺便给俺留个链接地址(谢谢撒),个人觉得不会太难,实现成跟苹果键盘的显示完全一样应该不是很困难,我第一个想做的是把下面代码中提到的“套子”给灭了,不过马上要工作。
哥们喜欢直接上代码或直接上图片,下面介绍一个简单的实例:
第一步,新建一个ViewController(带xib的),拖四个UITextField,建四个变量并且关联上,在h文件中实现UITextFieldDelegate,WDLKeyboardDelegate这个两个代理。
// // ViewController.h // WDLKeyboard // // Created by apple on 12-6-6. // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. // #import <UIKit/UIKit.h> #import "WDLKeyboard.h" @interface ViewController : UIViewController<UITextFieldDelegate,WDLKeyboardDelegate>{ IBOutlet UITextField *text_1;//默认显示数字键盘 IBOutlet UITextField *text_2;//默认显示小写字母键盘 IBOutlet UITextField *text_3;//默认显示大写字母键盘 IBOutlet UITextField *text_4;//默认数字密码键盘,且最多输入10位字符 int oldTextTag; } @end
第二步,在m文件中配置textField的delegate和WDLKeyboardDelegate
// // ViewController.m // WDLKeyboard // // Created by apple on 12-6-6. // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. // #import "ViewController.h" #import "WDLKeyboard.h" @implementation ViewController - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } #pragma mark - View lifecycle - (void)viewDidLoad { //设置代理 text_1.delegate = self; text_2.delegate = self; text_3.delegate = self; text_4.delegate = self; //设置标签 [text_1 setTag:1]; [text_2 setTag:2]; [text_3 setTag:3]; [text_4 setTag:4]; [super viewDidLoad]; } - (void)viewDidUnload { [super viewDidUnload]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return NO; } #pragma mark - UITextFieldDelegate - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ if (textField.tag == 1) { WDLKeyboard *keyboard = [[WDLKeyboard alloc]initWithFrame:CGRectZero keyboardType:KeyboardTypeNumKeyPad secureType:NO]; [keyboard setDelegate:self]; [keyboard showKeyboardView:textField.text]; } else if (textField.tag == 2) { WDLKeyboard *keyboard = [[WDLKeyboard alloc]initWithFrame:CGRectZero keyboardType:KeyboardTypeCharKeyPad secureType:NO]; [keyboard setDelegate:self]; [keyboard showKeyboardView:textField.text]; } else if (textField.tag == 3) { WDLKeyboard *keyboard = [[WDLKeyboard alloc]initWithFrame:CGRectZero keyboardType:KeyboardTypeUpperKeyCharPad secureType:NO]; [keyboard setDelegate:self]; [keyboard showKeyboardView:textField.text]; } else if (textField.tag == 4) { WDLKeyboard *keyboard = [[WDLKeyboard alloc]initWithFrame:CGRectZero keyboardType:KeyboardTypeNumKeyPad secureType:YES]; [keyboard setKeyboardValueMaxLength:10]; [keyboard setDelegate:self]; [keyboard showKeyboardView:textField.text]; } //加个背景用于区别 [textField setBackgroundColor:[UIColor lightGrayColor]]; //记录当前textFiled的标签,下面的keyboard代理中使用 oldTextTag = textField.tag; //返回NO将不会调出系统键盘 return NO; } #pragma mark - WDLKeyboardDelegate Methods -(void)wdlkeyboardView:(WDLKeyboard*)keyboardView doneWithValue:(NSString *)value{ UITextField *textField = (UITextField*)[self.view viewWithTag:oldTextTag]; [textField setText:value]; //恢复背景 [textField setBackgroundColor:[UIColor whiteColor]]; } @end
第三部,啥也不啥,贴出来WDLKeyboard这个类,自己看,注释都有滴。
// // WDLKeyboard.h // wdlKeyboard1 // // Created by wdl on 12-4-18. // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. // #define KeyboardView_Frame CGRectMake(0, 0, 320, 260) #define Num_FontSize 28 #define Char_FontSize 24 #define Small_FontSize 18 #define But_TextFontColor [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0] #define But_TextFontColor_Highlight [UIColor colorWithRed:0 green:0 blue:0 alpha:1.0] #define num_w 105 #define num_h 53 #define num_top 44 #define char_w 45 #define char_h 53 #define char_top 44 #define KBKey_Highlight @"KBKey_Highlight.png" #define KBKey_Default @"KBKey_Default.png" #define KBKey_Del_Default_1 @"KBKey_Del_Default_1.png" #define KBKey_Del_Highlight_1 @"KBKey_Del_Highlight_1.png" #define KBKey_Del_Default @"KBKey_Del_Default.png" #define KBKey_Del_Highlight @"KBKey_Del_Highlight.png" typedef enum{ KeyboardTypeNumKeyPad = 0, //字母键盘 KeyboardTypeCharKeyPad = 1, //小写键盘 KeyboardTypeUpperKeyCharPad = 2, //大写键盘 }KeyboardTypeEnum; #import <UIKit/UIKit.h> @protocol WDLKeyboardDelegate; @interface WDLKeyboard : UIView{ KeyboardTypeEnum keyboardType; // 键盘类型 id<WDLKeyboardDelegate>delegate; //代理 NSString *keyboardValue; //textField当前值 NSString *defaultValue; //textField初始值 NSInteger keyboardValueMaxLength; //最大长度 NSArray *numArray; //数字数字 NSArray *charArray; //小写字母数字 NSArray *upperCharArray; //大写字母数字 UIActionSheet *_actionSheet; UIToolbar *_topToolBar; UITextField *_txtInput; NSTimer *_timer; //定时器 } @property (nonatomic) KeyboardTypeEnum keyboardType; @property (nonatomic, assign) id<WDLKeyboardDelegate>delegate; @property (nonatomic, retain) NSString *keyboardValue; @property (nonatomic, retain) NSString *defaultValue; @property (nonatomic) NSInteger keyboardValueMaxLength; @property (nonatomic, retain) NSArray *numArray; @property (nonatomic, retain) NSArray *charArray; @property (nonatomic, retain) NSArray *upperCharArray; @property (nonatomic, retain, readonly) NSTimer *timer; -(id)initWithFrame:(CGRect)frame keyboardType:(KeyboardTypeEnum)kType secureType:(BOOL) sType; -(void)CustomKeyboardViewDismiss; -(void)CustomKeyboardViewSubmit; -(void)showKeyboardView:(NSString*)inputValue; -(IBAction)keyPress:(id)sender; -(void)changeKeyboardType; -(IBAction)delKeyPressBegin:(id)sender; -(IBAction)delKeyPressEnd:(id)sender; -(void)delTextValue; @end @protocol WDLKeyboardDelegate @required //代理 -(void)wdlkeyboardView:(WDLKeyboard*)keyboardView doneWithValue:(NSString *)value; @end
// // WDLKeyboard.m // wdlKeyboard1 // // Created by wdl on 12-4-18. // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. // #import "WDLKeyboard.h" @implementation WDLKeyboard @synthesize keyboardType; @synthesize delegate; @synthesize keyboardValue; @synthesize defaultValue; @synthesize keyboardValueMaxLength; @synthesize numArray; @synthesize charArray; @synthesize upperCharArray; @dynamic timer; #pragma mark - #pragma mark timer - (NSTimer *)timer { return _timer; } - (void)setTimer:(NSTimer *)newTimer { [_timer invalidate]; [newTimer retain]; [_timer release]; _timer = newTimer; } -(void)stopTimer{ self.timer = nil; } - (id)initWithFrame:(CGRect)frame keyboardType:(KeyboardTypeEnum)kType secureType:(BOOL) sType{ self = [super initWithFrame:frame]; if (self) { [self setOpaque:NO]; [self setBackgroundColor:[UIColor blackColor]]; [self setFrame:KeyboardView_Frame]; //数组定义 numArray = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"abc",@"0",@" ",nil]; charArray = [[NSArray alloc]initWithObjects:@"a",@"b",@"c",@"d",@"e", @"f",@"g",@"h",@"i",@"j", @"k",@"l",@"m",@"n",@"o", @"p",@"q",@"r",@"s",@"t", @"u",@"ABC",@"v",@"w",@"x",@"y", @"z",@" ",nil]; upperCharArray = [[NSArray alloc]initWithObjects:@"A",@"B",@"C",@"D",@"E", @"F",@"G",@"H",@"I",@"J", @"K",@"L",@"M",@"N",@"O", @"P",@"Q",@"R",@"S",@"T", @"U",@"123",@"V",@"W",@"X",@"Y", @"Z",@" ",nil]; //外套 NSString *actionSheetTitle = UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation) ? @"\n\n\n\n\n\n\n\n\n\n" : @"\n\n\n\n\n\n\n\n\n\n\n\n\n"; _actionSheet = [[[UIActionSheet alloc] initWithTitle:actionSheetTitle delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil] autorelease]; //文本标签 CGRect txtInputFrame = CGRectMake( 0, 0, 200, 31); _txtInput = [[[UITextField alloc] initWithFrame:txtInputFrame] autorelease]; [_txtInput setEnabled:NO]; [_txtInput setTextAlignment:UITextAlignmentLeft]; [_txtInput setFont:[UIFont systemFontOfSize:16]]; [_txtInput setBackgroundColor:[UIColor clearColor]]; [_txtInput setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter]; [_txtInput setBorderStyle:UITextBorderStyleRoundedRect]; //ios4.2和之前的版本UITextField是不透明白色背景,而气体也是白色,所以会造成看不到文本值的先下,下面特别处理了下字体颜色 Class ios5Class = (NSClassFromString(@"CIImage")); if (nil != ios5Class) { [_txtInput setTextColor:[UIColor whiteColor]]; }else{ [_txtInput setTextColor:[UIColor blackColor]]; } //设置是否是密码键盘 [_txtInput setSecureTextEntry:sType]; //工具栏 CGRect topToolBarFrame = CGRectMake( 0, 0, 320, 44); _topToolBar = [[[UIToolbar alloc] initWithFrame:topToolBarFrame] autorelease]; _topToolBar.barStyle = UIBarStyleBlack; UIBarButtonItem *cancelItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStyleBordered target:self action:@selector(CustomKeyboardViewDismiss)]; UIBarButtonItem *spaceItemLeft = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; UIBarButtonItem *inputItem = [[UIBarButtonItem alloc] initWithCustomView:_txtInput]; UIBarButtonItem *spaceItemRight = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; UIBarButtonItem *doneItem = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonItemStyleDone target:self action:@selector(CustomKeyboardViewSubmit)]; [_topToolBar setItems:[NSArray arrayWithObjects:cancelItem,spaceItemLeft,inputItem,spaceItemRight,doneItem,nil]]; [self addSubview:_topToolBar]; //数字键 for (int i=0; i<12; i++) { float kx ; float ky ; kx = 1 + i%3 * num_w + i%3; ky = num_top + i/3 * num_h + i/3; UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom]; [bt setTag:(1000+i)]; [bt setFrame:CGRectMake(kx, ky, num_w, num_h)]; [bt setTitle:[numArray objectAtIndex:i] forState:UIControlStateNormal]; if (i == 9) { [bt addTarget:self action:@selector(keyPress:) forControlEvents:UIControlEventTouchUpInside]; [bt.titleLabel setFont:[UIFont boldSystemFontOfSize:Num_FontSize]]; [bt setTitleColor:But_TextFontColor_Highlight forState:UIControlStateNormal]; [bt setTitleColor:But_TextFontColor forState:UIControlStateHighlighted]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Highlight] forState:UIControlStateNormal]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Default] forState:UIControlStateHighlighted]; } else if (i == 11){ [bt addTarget:self action:@selector(delKeyPressBegin:) forControlEvents:UIControlEventTouchDown]; [bt addTarget:self action:@selector(delKeyPressEnd:) forControlEvents:UIControlEventTouchUpInside]; [bt addTarget:self action:@selector(delKeyPressEnd:) forControlEvents:UIControlEventTouchUpOutside]; [bt.titleLabel setFont:[UIFont boldSystemFontOfSize:Num_FontSize]]; [bt setTitleColor:But_TextFontColor_Highlight forState:UIControlStateNormal]; [bt setTitleColor:But_TextFontColor forState:UIControlStateHighlighted]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Del_Default] forState:UIControlStateNormal]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Del_Highlight] forState:UIControlStateHighlighted]; } else { [bt addTarget:self action:@selector(keyPress:) forControlEvents:UIControlEventTouchUpInside]; [bt.titleLabel setFont:[UIFont boldSystemFontOfSize:Num_FontSize]]; [bt setTitleColor:But_TextFontColor forState:UIControlStateNormal]; [bt setTitleColor:But_TextFontColor_Highlight forState:UIControlStateHighlighted]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Default] forState:UIControlStateNormal]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Highlight] forState:UIControlStateHighlighted]; } //设置是否显示当前类型的键盘 if (kType != KeyboardTypeNumKeyPad) { [bt setHidden:YES]; } [self addSubview:bt]; } //小写字母键 for (int i=0; i<28; i++) { float kx ; float ky ; kx = 1 + i%7 * char_w + i%7; ky = char_top + i/7 * char_h + i/7; UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom]; [bt setTag:(2000+i)]; [bt setFrame:CGRectMake(kx, ky, char_w, char_h)]; [bt setTitle:[charArray objectAtIndex:i] forState:UIControlStateNormal]; if (i == 21) { [bt addTarget:self action:@selector(keyPress:) forControlEvents:UIControlEventTouchUpInside]; [bt.titleLabel setFont:[UIFont boldSystemFontOfSize:Small_FontSize]]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Highlight] forState:UIControlStateNormal]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Default] forState:UIControlStateHighlighted]; [bt setTitleColor:But_TextFontColor_Highlight forState:UIControlStateNormal]; [bt setTitleColor:But_TextFontColor forState:UIControlStateHighlighted]; } else if (i == 27){ [bt addTarget:self action:@selector(delKeyPressBegin:) forControlEvents:UIControlEventTouchDown]; [bt addTarget:self action:@selector(delKeyPressEnd:) forControlEvents:UIControlEventTouchUpInside]; [bt addTarget:self action:@selector(delKeyPressEnd:) forControlEvents:UIControlEventTouchUpOutside]; [bt.titleLabel setFont:[UIFont boldSystemFontOfSize:Small_FontSize]]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Del_Default_1] forState:UIControlStateNormal]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Del_Highlight_1] forState:UIControlStateHighlighted]; [bt setTitleColor:But_TextFontColor_Highlight forState:UIControlStateNormal]; [bt setTitleColor:But_TextFontColor forState:UIControlStateHighlighted]; } else { [bt addTarget:self action:@selector(keyPress:) forControlEvents:UIControlEventTouchUpInside]; [bt.titleLabel setFont:[UIFont boldSystemFontOfSize:Char_FontSize]]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Default] forState:UIControlStateNormal]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Highlight] forState:UIControlStateHighlighted]; [bt setTitleColor:But_TextFontColor forState:UIControlStateNormal]; [bt setTitleColor:But_TextFontColor_Highlight forState:UIControlStateHighlighted]; } if (kType != KeyboardTypeCharKeyPad) { [bt setHidden:YES]; } [self addSubview:bt]; } //大写字母键 for (int i=0; i<28; i++) { float kx ; float ky ; kx = 1 + i%7 * char_w + i%7; ky = char_top + i/7 * char_h + i/7; UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom]; [bt setTag:(3000+i)]; [bt setFrame:CGRectMake(kx, ky, char_w, char_h)]; [bt setTitle:[upperCharArray objectAtIndex:i] forState:UIControlStateNormal]; if (i ==21) { [bt addTarget:self action:@selector(keyPress:) forControlEvents:UIControlEventTouchUpInside]; [bt.titleLabel setFont:[UIFont boldSystemFontOfSize:Small_FontSize]]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Highlight] forState:UIControlStateNormal]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Default] forState:UIControlStateHighlighted]; [bt setTitleColor:But_TextFontColor_Highlight forState:UIControlStateNormal]; [bt setTitleColor:But_TextFontColor forState:UIControlStateHighlighted]; } else if (i == 27) { [bt addTarget:self action:@selector(delKeyPressBegin:) forControlEvents:UIControlEventTouchDown]; [bt addTarget:self action:@selector(delKeyPressEnd:) forControlEvents:UIControlEventTouchUpInside]; [bt addTarget:self action:@selector(delKeyPressEnd:) forControlEvents:UIControlEventTouchUpOutside]; [bt.titleLabel setFont:[UIFont boldSystemFontOfSize:Small_FontSize]]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Del_Default_1] forState:UIControlStateNormal]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Del_Highlight_1] forState:UIControlStateHighlighted]; [bt setTitleColor:But_TextFontColor_Highlight forState:UIControlStateNormal]; [bt setTitleColor:But_TextFontColor forState:UIControlStateHighlighted]; } else { [bt addTarget:self action:@selector(keyPress:) forControlEvents:UIControlEventTouchUpInside]; [bt.titleLabel setFont:[UIFont boldSystemFontOfSize:Char_FontSize]]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Default] forState:UIControlStateNormal]; [bt setBackgroundImage:[UIImage imageNamed:KBKey_Highlight] forState:UIControlStateHighlighted]; [bt setTitleColor:But_TextFontColor forState:UIControlStateNormal]; [bt setTitleColor:But_TextFontColor_Highlight forState:UIControlStateHighlighted]; } if (kType != KeyboardTypeUpperKeyCharPad) { [bt setHidden:YES]; } [self addSubview:bt]; } keyboardType = kType; //把当前view装进套子,就暂且叫套子吧,哈哈,也不知道改叫它啥玩意。 [_actionSheet addSubview:self]; } return self; } //取消按钮 -(void)CustomKeyboardViewDismiss{ [self.delegate wdlkeyboardView:self doneWithValue:defaultValue]; [_actionSheet dismissWithClickedButtonIndex:0 animated:YES]; } //确认按钮 -(void)CustomKeyboardViewSubmit{ [self.delegate wdlkeyboardView:self doneWithValue:keyboardValue]; [_actionSheet dismissWithClickedButtonIndex:0 animated:YES]; } //一般键盘 -(IBAction)keyPress:(id)sender{ UIButton *butItem = (UIButton*)sender; NSString *butTitle = butItem.titleLabel.text; if ([butTitle isEqualToString:@"abc"] || [butTitle isEqualToString:@"ABC"] || [butTitle isEqualToString:@"123"]) { //更换当前键盘类型 [self changeKeyboardType]; } else { //更改当前文本值 if (keyboardValueMaxLength > 0) { if ([keyboardValue length] < keyboardValueMaxLength) { keyboardValue = [NSString stringWithFormat:@"%@%@",keyboardValue,butTitle]; } } else { keyboardValue = [NSString stringWithFormat:@"%@%@",keyboardValue,butTitle]; } [_txtInput setText:keyboardValue]; } } //开始执行删除 -(IBAction)delKeyPressBegin:(id)sender{ //执行删除 [self delTextValue]; //开启Timer self.timer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(delTextValue) userInfo:nil repeats:YES]; } //结束执行删除 -(IBAction)delKeyPressEnd:(id)sender{ //停止Timer [self stopTimer]; } //删除文本值 -(void)delTextValue{ if (keyboardValue.length > 0) { keyboardValue = [keyboardValue substringToIndex:(keyboardValue.length-1)]; [_txtInput setText:keyboardValue]; } } //显示键盘 -(void)showKeyboardView:(NSString*)inputValue{ defaultValue = inputValue; keyboardValue = inputValue; [_txtInput setText:inputValue]; UIViewController *viewController = (UIViewController*)delegate; [_actionSheet showInView:viewController.view.window]; } //更改键盘类型 -(void)changeKeyboardType{ if (keyboardType == KeyboardTypeNumKeyPad) { for (int i=0; i<12; i++) { int oldButTag = (1000+i); UIButton *oldBut = (UIButton *)[self viewWithTag:oldButTag]; [oldBut setHidden:YES]; } for (int i=0; i<28; i++) { int oldButTag = (2000+i); UIButton *oldBut = (UIButton *)[self viewWithTag:oldButTag]; [oldBut setHidden:NO]; } keyboardType = KeyboardTypeCharKeyPad; } else if (keyboardType == KeyboardTypeCharKeyPad) { for (int i=0; i<28; i++) { int oldButTag = (2000+i); UIButton *oldBut = (UIButton *)[self viewWithTag:oldButTag]; [oldBut setHidden:YES]; } for (int i=0; i<28; i++) { int oldButTag = (3000+i); UIButton *oldBut = (UIButton *)[self viewWithTag:oldButTag]; [oldBut setHidden:NO]; } keyboardType = KeyboardTypeUpperKeyCharPad; } else if (keyboardType == KeyboardTypeUpperKeyCharPad) { for (int i=0; i<28; i++) { int oldButTag = (3000+i); UIButton *oldBut = (UIButton *)[self viewWithTag:oldButTag]; [oldBut setHidden:YES]; } for (int i=0; i<12; i++) { int oldButTag = (1000+i); UIButton *oldBut = (UIButton *)[self viewWithTag:oldButTag]; [oldBut setHidden:NO]; } keyboardType = KeyboardTypeNumKeyPad; } } @end
第四步,贴图。
第五步,上工程代码,下面有项目代码,灰常小。