一个让我不舒服的自定义键盘
来源:互联网 发布:淘宝店铺上传宝贝视频 编辑:程序博客网 时间:2024/04/27 08:08
根据需求做,真的好恶心,但是仔细研究一下蛮简单的
刚开始做的时候,要关闭原生键盘的弹出
self.sellingPricetext.inputView = [[UIView alloc] initWithFrame:CGRectZero];
[self.sellingPricetext setDelegate:self];
self.originalPriceText.inputView = [[UIView alloc] initWithFrame:CGRectZero];
[self.originalPriceText setDelegate:self];
键盘输入的界面我是用xib画的,简单,但是后期改动麻烦
输入的时候需要用NSMutableString来接受输入的值
self.string1 = [NSMutableString string];
self.string2 = [NSMutableString string];
这些是主要代码,逻辑并不复杂,刚开始做的时候是不知道该如何下手
(IBAction)chooseTheDigital:(UIButton *)sender {
if ([self.keybordType isEqualToString:@”0”]) {
[self showHint:@”请选择出售价格或者原价”];
return;
}if ([self.keybordType isEqualToString:@”1”]) {
[self.string1 appendString:sender.currentTitle];
self.sellingPricetext.text = self.string1;//原价
}if ([self.keybordType isEqualToString:@"2"]) {[self.string2 appendString:sender.currentTitle];self.originalPriceText.text = self.string2;//出售价}
}
(IBAction)dele:(UIButton *)sender {
if ([self.keybordType isEqualToString:@”0”]) {
[self showHint:@”没输入原价或者出售价”];
return;
}if ([self.keybordType isEqualToString:@”1”]) {
if ([self.sellingPricetext.text isEqualToString:@”“]) {
[self showHint:@”请输入原价”];}else{[self.string1 deleteCharactersInRange:NSMakeRange(self.string1.length-1, 1)];self.sellingPricetext.text = self.string1;}
}
if ([self.keybordType isEqualToString:@”2”]) {
if ([self.originalPriceText.text isEqualToString:@”“]) {
[self showHint:@”请输入出售价”];}else{ [self.string2 deleteCharactersInRange:NSMakeRange(self.string2.length-1, 1)]; self.originalPriceText.text = self.string2;}
}
}
- (IBAction)yesBuy:(UIButton *)sender {
sender.selected = !sender.selected;
if (sender.selected) { _yesBuy.selected = YES; _noBuy.selected = NO; self.buyType = @"1"; self.originalPriceText.userInteractionEnabled = YES;}else{ _yesBuy.selected = NO;}
}
(IBAction)noBuy:(UIButton *)sender {
sender.selected = !sender.selected;
if (sender.selected) {
_noBuy.selected = YES;
_yesBuy.selected = NO;
self.buyType = @”0”;
self.originalPriceText.text = @”“;
self.originalPriceText.userInteractionEnabled = NO;
self.string2 = [[NSMutableString alloc] init];
}else{
_noBuy.selected = NO;
}
}(IBAction)priceSure:(UIButton *)sender {
if ([self.sellingPricetext.text isEqualToString:@”“]) {
[self showHint:@”请输入原价”];
return;
}if ([self.sellingPricetext.text floatValue] < [self.originalPriceText.text floatValue]) {
[self showHint:@”出售价格不能大于原价”];
return;
}if ([self.buyType isEqualToString:@”1”]) {
if ([self.originalPriceText.text isEqualToString:@”“]) {
[self showHint:@”请输入出售价”];
return;
}if ([self.sellingPricetext.text isEqualToString:@""]) { [self showHint:@"请输入原价"]; return;}[self.sellingPriceBtn setTitle:self.originalPriceText.text forState:UIControlStateNormal];[self.sellingPriceBtn setTitleColor:[UIColor colorWithRed:234/255.0 green:102/255.0 blue:135/255.0 alpha:1.0] forState:UIControlStateNormal];
[self hiddenPasswordView];
}if ([self.buyType isEqualToString:@”0”]) {
[self hiddenPasswordView];
// [self.sellingPriceBtn setTitle:self.sellingPriceBtn.titleLabel.text forState:UIControlStateNormal];
[self.sellingPriceBtn setTitle:@”不支持购买” forState:UIControlStateNormal];
[self.sellingPriceBtn setTitleColor:[UIColor colorWithRed:234/255.0 green:102/255.0 blue:135/255.0 alpha:1.0] forState:UIControlStateNormal];
}
}
- 一个让我不舒服的自定义键盘
- 让人不舒服的人
- 不舒服的说
- 的法规不舒服
- 李而亮的几点意见中为什么让人听起来如此不舒服
- 让BIOS告诉您电脑哪不舒服
- 想说说心里的不舒服
- 一个让我瞠目结舌的电脑高手!
- 一个让我迷惑的结果
- 一个让我感动的 smd,sigh
- 一个让我面壁思过的低级错误!
- 一个让我蛋疼的功能。。。。
- 东莞,一个让我梦想的“天堂”......
- 让我兴奋的一个帖子
- 一个让我哭泣的朋友
- 一个程序员的忠告让我感慨万千
- 让我很纠结的一个问题
- 一个让我很无语的bug
- Elasticsearch5.X head插件安装
- Xcode免证书调试
- (原创题) 四边形面积 (三角函数+余弦定理或者海伦公式)
- 阿里免费教你学习前端开发CSS基础
- RocketMQ(一)
- 一个让我不舒服的自定义键盘
- MFC:重绘GroupBox控件
- 网易2018笔试题七
- Java源码编译机制、类加载机制、类执行机制
- 【PDF下载】红包在线技术峰会之红包背后:红与黑的较量
- 设计模式(Design Patterns)
- httpclient详解
- HTML5语法
- RocketMQ(二)