- 浏览: 200505 次
- 性别:
- 来自: 安徽
-
最新评论
-
dailuwen:
如果 日期类型里面 有 年月 和 年月日 一同存在的呢?
Spring表单提交日期类型绑定 -
jmwasky:
还真是。。别人写的都用不了,在这里找到问题所在了。。
spring的hibernateTemplate中执行sql语句 -
ta3225824:
你好 楼主 我也遇见同样的问题 向你请教 怎么解决的 ...
ios开发值异常-NSInvalidArgumentException NSCFString md5Hash -
anbo724:
为什么我这边提示ABRecordCopyValue 找不到呢? ...
ios调用通讯录数据 -
nbboy:
去哪儿面试?
长达十五个小时的面试!程序员终极面试!
一直往下拉有截图,忍不住啰嗦的朋友看图先!
以前有篇文章发了个键盘,现在这个把代码和功能优化了些许,介绍一下键盘功能:
(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
第四步,贴图。
第五步,上工程代码,下面有项目代码,灰常小。
- WDLKeyboard.zip (118.2 KB)
- 下载次数: 62
发表评论
-
发布应用时,第三方库Three20应将代码中调试用的私有 API 注释或删除掉。
2012-10-11 11:23 1254修改方案: a.Three20_1_0_ ... -
ios客户端浏览器访问本地html文件
2012-10-11 11:21 2217NSString *mainBu ... -
popToViewController用法
2012-10-09 09:43 13901popToViewController用法: 第一种: ... -
objective-c和IOS文章收集
2012-09-25 12:07 1087个人笔记,持续更新…… 每天看三篇博客,坚持…… ... -
XCode打包项目Framework
2012-09-24 15:44 18393下文是转载,本人觉得这个打包framework还是一个比 ... -
retain和copy还有assign的区别
2012-09-05 14:42 10461. 假设你用malloc分配了一块内存,并且把它的地址赋值给 ... -
ios开发值异常-NSInvalidArgumentException NSCFString md5Hash
2012-08-16 14:56 4709Application Specific Informa ... -
ios开发中遇到的解析json出错之Unescaped control character '0x9'
2012-08-15 16:31 5420Error Domain=org.brautas ... -
Error launching remote program: No such file or directory
2012-07-24 10:08 1646iPhone真机调试报如下错误时,关掉Xcode,重新启 ... -
ios发布遇到的一小问题:This bundle is invalid.
2012-07-01 19:22 2885ios发布的时候可能回遇到这个错误: 错误 ... -
objective-c基本数据类型之输出格式符
2012-06-15 09:31 2958基本数据类型 1. int 输出格式符:%i, ... -
UIDIvice的几个拓展功能(获取唯一标示、判断是否越狱)
2012-05-14 19:07 4172最近的项目中用到了几个比较不常用的方法: (1)获取设 ... -
iphone自定义键盘
2012-04-19 19:19 2457直接上图,你懂的。 -
ios项目绕过证书访问https程序
2012-04-18 21:20 18042如果是单个的webview或者request请求,在请求的文件 ... -
ios按钮点击后翻转效果
2012-03-21 23:17 14233上图先,图上是一个按钮,点击后旋转,代码是网上找到的,不过找到 ... -
ios调用通讯录数据
2012-03-15 22:03 4333(1)第一步,引入“AddressBook.framewo ... -
让最新的three20在xcode4.2下跑起来吧
2012-03-14 21:28 3592也不太会“写字”, ... -
iphone&ipad图标去除高亮的光圈效果
2012-03-13 22:11 2699苹果默认会在 App Store 里的应用图标上半部自动添加高 ... -
iphone,ipad,关于icon图标的那些事
2012-03-13 21:57 7043我们的辛辛苦苦做出来的应用程序在iPhone上的表示仅仅是一个 ... -
[BEROR]Code Sign error: Provisioning profile 'xxxxxxxxx' can't be found
2012-02-29 17:01 1955[BEROR]Code Sign error: Prov ...
相关推荐
5. **键盘切换逻辑**: 在某些情况下,用户可能需要在数字键盘和其他类型的键盘(如字母键盘)之间切换。自定义键盘需要处理这种切换逻辑,可能通过手势或特定按钮来触发。 6. **键盘高度和显示模式**: 自定义键盘的...
3. **键盘字母和数字随机排列**: 这一点是为了增加键盘的不可预测性,使得潜在的攻击者难以通过记忆键盘布局来猜测用户输入的密码。这可以通过在代码中动态设置键盘按钮的标签和位置来实现。 4. **安全性考量**:...
iPhone用户可以通过长按数字键盘上的“123”键,并滑动至所需标点符号上释放,实现快速切换。此外,输入标点后按空格键,键盘会自动切换回字母模式,对于英文输入尤为便捷。双击空格键,可自动插入句号“.”,进一步...
【标题】:“雅圆最终修改版”指的是一个针对iOS系统的个性化字体包,它经过了精心的修改和优化,旨在为用户带来独特的视觉体验。这款字体以其优雅和圆润的字形设计,为iOS设备增添了浪漫的氛围,尤其适用于喜欢个性...
5. 特殊字符和符号:iOS输入法提供了丰富的特殊字符和符号,通过长按特定键或通过“地球”键切换到数字和标点符号键盘。此项目可能仅实现了基本的字符集,高级功能可能尚未完善。 6. 用户词典:用户可以添加自定义...
- **正则判断**: 使用正则表达式来验证字符串是否只包含字母和数字。 - **修改 UITableview 滚动条颜色**: 通过设置 `UIScrollView` 的 `indicatorStyle` 属性来改变滚动条的颜色。 #### 15. 文件操作 - **下文件...